Class AdviceController

java.lang.Object
org.example.crmedu.application.controller.AdviceController

@ControllerAdvice public class AdviceController extends Object
Global exception handler for handling application-wide exceptions. Provides centralized exception processing and returns appropriate HTTP responses.
  • Constructor Details

    • AdviceController

      public AdviceController()
  • Method Details

    • handleEntityNotFoundException

      @ExceptionHandler(EntityNotFoundException.class) public org.springframework.http.ResponseEntity<SystemError> handleEntityNotFoundException(EntityNotFoundException e)
      Handles EntityNotFoundException and returns a 404 Not Found response.
      Parameters:
      e - the thrown exception
      Returns:
      a ResponseEntity containing a SystemError object with error details
    • handleEntityExistsException

      @ExceptionHandler(EntityExistsException.class) public org.springframework.http.ResponseEntity<SystemError> handleEntityExistsException(EntityExistsException e)
      Handles EntityExistsException and returns a 400 Bad Request response.
      Parameters:
      e - the thrown exception
      Returns:
      a ResponseEntity containing a SystemError object with error details
    • handleTutorScheduleOverlapsException

      @ExceptionHandler(TutorScheduleOverlapsException.class) public org.springframework.http.ResponseEntity<SystemError> handleTutorScheduleOverlapsException(TutorScheduleOverlapsException e)
      Handles TutorScheduleOverlapsException and returns a 400 Bad Request response.
      Parameters:
      e - the thrown exception
      Returns:
      a ResponseEntity containing a SystemError object with error details
    • handleMethodArgumentNotValidException

      @ExceptionHandler(org.springframework.web.bind.MethodArgumentNotValidException.class) public org.springframework.http.ResponseEntity<ValidationErrorResponse> handleMethodArgumentNotValidException(org.springframework.web.bind.MethodArgumentNotValidException e)
      Handles a MethodArgumentNotValidException and returns an HTTP 400 Bad Request response.

      This exception is thrown when validation on an argument annotated with @Valid fails. The method extracts field validation errors and returns them in a structured response.

      Parameters:
      e - the exception containing validation errors
      Returns:
      a ResponseEntity containing a ValidationErrorResponse with the list of validation violations