package com.example.nto.exception.handler; import com.example.nto.exception.*; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; @ControllerAdvice public class GlobalExceptionHandler { @ExceptionHandler(EmployeeNotFoundException.class) public ResponseEntity handleEmployeeNotFoundException(EmployeeNotFoundException e) { return new ResponseEntity<>(e.getMessage(), HttpStatus.UNAUTHORIZED); } @ExceptionHandler(BookingAlreadyExistsException.class) public ResponseEntity handleBookingAlreadyExistsException(BookingAlreadyExistsException e) { return new ResponseEntity<>(e.getMessage(), HttpStatus.CONFLICT); } @ExceptionHandler(PlaceNotFoundException.class) public ResponseEntity handlePlaceNotFoundException(PlaceNotFoundException e) { return new ResponseEntity<>(e.getMessage(), HttpStatus.BAD_REQUEST); } @ExceptionHandler(EmployeeAlreadyExistsException.class) public ResponseEntity handleEmployeeAlreadyExistsException(EmployeeAlreadyExistsException e) { return new ResponseEntity<>(e.getMessage(), HttpStatus.CONFLICT); } @ExceptionHandler(PasswordNotCorrectException.class) public ResponseEntity handlePasswordNotCorrectException(PasswordNotCorrectException e) { return new ResponseEntity<>(e.getMessage(), HttpStatus.CONFLICT); } @ExceptionHandler(Exception.class) public ResponseEntity handleGenericException(Exception e) { return new ResponseEntity<>(e.getMessage(), HttpStatus.BAD_REQUEST); } }