init
Some checks failed
Android Test / validate-and-test (pull_request) Has been cancelled

This commit is contained in:
2025-11-30 19:49:37 +07:00
parent a6954c2013
commit bbe7d1ea6c
17 changed files with 322 additions and 24 deletions

View File

@@ -0,0 +1,7 @@
package com.example.nto.Exception;
public class BookingConflictException extends RuntimeException {
public BookingConflictException(String message) {
super(message);
}
}

View File

@@ -0,0 +1,7 @@
package com.example.nto.Exception;
public class EmployeeNotFoundException extends RuntimeException {
public EmployeeNotFoundException(String message) {
super(message);
}
}

View File

@@ -0,0 +1,30 @@
package com.example.nto.Exception;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@RestControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler(EmployeeNotFoundException.class)
public ResponseEntity<String> EmployeeNotFoundException(EmployeeNotFoundException ex) {
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(ex.getMessage());
}
@ExceptionHandler(PlaceNotFoundException.class)
public ResponseEntity<String> PlaceNotFoundException(PlaceNotFoundException ex) {
return ResponseEntity.badRequest().body("Что-то пошло не так");
}
@ExceptionHandler(BookingConflictException.class)
public ResponseEntity<String> BookingConflictException(BookingConflictException ex) {
return ResponseEntity.status(HttpStatus.CONFLICT).body(ex.getMessage());
}
@ExceptionHandler(Exception.class)
public ResponseEntity<String> Exception(Exception ex) {
return ResponseEntity.badRequest().body("Что-то пошло не так");
}
}

View File

@@ -0,0 +1,7 @@
package com.example.nto.Exception;
public class PlaceNotFoundException extends RuntimeException {
public PlaceNotFoundException(String message) {
super(message);
}
}