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 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 messages
      request - the current HTTP request
      Returns:
      a ModelAndView with 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 exception
      request - the current HTTP request
      Returns:
      a ModelAndView with 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 exception
      request - the current HTTP request
      Returns:
      a ModelAndView with a generic error page