Class AdviceController
java.lang.Object
org.example.crmedu.application.controller.AdviceController
Global exception handler for handling application-wide exceptions. Provides centralized exception processing and returns appropriate HTTP responses.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity
<SystemError> HandlesEntityExistsException
and returns a 400 Bad Request response.org.springframework.http.ResponseEntity
<SystemError> HandlesEntityNotFoundException
and returns a 404 Not Found response.org.springframework.http.ResponseEntity
<ValidationErrorResponse> handleMethodArgumentNotValidException
(org.springframework.web.bind.MethodArgumentNotValidException e) Handles aMethodArgumentNotValidException
and returns an HTTP 400 Bad Request response.org.springframework.http.ResponseEntity
<SystemError> HandlesTutorScheduleOverlapsException
and returns a 400 Bad Request response.
-
Constructor Details
-
AdviceController
public AdviceController()
-
-
Method Details
-
handleEntityNotFoundException
@ExceptionHandler(EntityNotFoundException.class) public org.springframework.http.ResponseEntity<SystemError> handleEntityNotFoundException(EntityNotFoundException e) HandlesEntityNotFoundException
and returns a 404 Not Found response.- Parameters:
e
- the thrown exception- Returns:
- a
ResponseEntity
containing aSystemError
object with error details
-
handleEntityExistsException
@ExceptionHandler(EntityExistsException.class) public org.springframework.http.ResponseEntity<SystemError> handleEntityExistsException(EntityExistsException e) HandlesEntityExistsException
and returns a 400 Bad Request response.- Parameters:
e
- the thrown exception- Returns:
- a
ResponseEntity
containing aSystemError
object with error details
-
handleTutorScheduleOverlapsException
@ExceptionHandler(TutorScheduleOverlapsException.class) public org.springframework.http.ResponseEntity<SystemError> handleTutorScheduleOverlapsException(TutorScheduleOverlapsException e) HandlesTutorScheduleOverlapsException
and returns a 400 Bad Request response.- Parameters:
e
- the thrown exception- Returns:
- a
ResponseEntity
containing aSystemError
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 aMethodArgumentNotValidException
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 aValidationErrorResponse
with the list of validation violations
-