Class EnduranceTrioExceptionHandlerWeb
java.lang.Object
com.endurancetrio.app.common.handler.EnduranceTrioExceptionHandlerWeb
@ControllerAdvice(annotations=EnduranceTrioWebController.class)
public class EnduranceTrioExceptionHandlerWeb
extends Object
The
EnduranceTrioExceptionHandlerWeb class is a global exception handler for Thymeleaf
web controllers in the EnduranceTrio application.
This class intercepts exceptions thrown from controllers annotated with
EnduranceTrioWebController and renders an HTML error page with consistent layout (head,
navbar, footer) and error information.
-
Constructor Summary
ConstructorsConstructorDescriptionEnduranceTrioExceptionHandlerWeb(MessageService messageService, AppProperties appProperties) -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.web.servlet.ModelAndViewhandleDataIntegrity(@NonNull org.springframework.dao.DataIntegrityViolationException ex, @NonNull jakarta.servlet.http.HttpServletRequest request) Intercepts database integrity violations, such as unique constraint conflicts or foreign key violations.org.springframework.web.servlet.ModelAndViewhandleEnduranceTrioException(@NonNull EnduranceTrioException exception, @NonNull jakarta.servlet.http.HttpServletRequest request) Handles business logic exceptions defined within the EnduranceTrio domain.org.springframework.web.servlet.ModelAndViewhandleUnhandledException(@NonNull Exception exception, @NonNull jakarta.servlet.http.HttpServletRequest request) Catch-all handler for any unexpected system exceptions.
-
Constructor Details
-
EnduranceTrioExceptionHandlerWeb
@Autowired public EnduranceTrioExceptionHandlerWeb(MessageService messageService, AppProperties appProperties)
-
-
Method Details
-
handleEnduranceTrioException
@ExceptionHandler(EnduranceTrioException.class) public org.springframework.web.servlet.ModelAndView handleEnduranceTrioException(@NonNull EnduranceTrioException exception, @NonNull jakarta.servlet.http.HttpServletRequest request) Handles business logic exceptions defined within the EnduranceTrio domain. The HTTP status code is resolved from the exception's error code.- Parameters:
exception- the domain exception containing error codes and messagesrequest- the current HTTP request- Returns:
- a
ModelAndViewwith the error page
-
handleDataIntegrity
@ExceptionHandler(org.springframework.dao.DataIntegrityViolationException.class) public org.springframework.web.servlet.ModelAndView handleDataIntegrity(@NonNull org.springframework.dao.DataIntegrityViolationException ex, @NonNull jakarta.servlet.http.HttpServletRequest request) Intercepts database integrity violations, such as unique constraint conflicts or foreign key violations.- Parameters:
ex- the data integrity violation exceptionrequest- the current HTTP request- Returns:
- a
ModelAndViewwith a conflict error page
-
handleUnhandledException
@ExceptionHandler(java.lang.Exception.class) public org.springframework.web.servlet.ModelAndView handleUnhandledException(@NonNull Exception exception, @NonNull jakarta.servlet.http.HttpServletRequest request) Catch-all handler for any unexpected system exceptions. Maps unknown errors to a generic 500 Internal Server Error page.- Parameters:
exception- the unexpected exceptionrequest- the current HTTP request- Returns:
- a
ModelAndViewwith a generic error page
-