Class IdAuthExceptionHandler


  • @RestControllerAdvice
    public class IdAuthExceptionHandler
    extends org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
    The Class IDAExceptionHandler - Spring MVC Exceptions as defined in ResponseEntityExceptionHandler and any other Exceptions occurs and returns custom exception response AuthResponseDTO.
    Author:
    Manoj SP, Mamta A
    • Field Summary

      • Fields inherited from class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler

        logger, PAGE_NOT_FOUND_LOG_CATEGORY, pageNotFoundLogger
    • Constructor Summary

      Constructors 
      Constructor Description
      IdAuthExceptionHandler()
      Instantiates a new id auth exception handler.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static Object buildExceptionResponse​(Exception ex, javax.servlet.http.HttpServletRequest request)
      Constructs exception response body for all exceptions.
      static Object buildExceptionResponse​(Exception ex, javax.servlet.http.HttpServletRequest request, List<AuthError> errors)  
      static List<AuthError> getAuthErrors​(Exception ex)  
      protected org.springframework.http.ResponseEntity<Object> handleAllExceptions​(Exception ex, org.springframework.web.context.request.WebRequest request)
      Handle all exceptions.
      protected org.springframework.http.ResponseEntity<Object> handleExceptionInternal​(Exception ex, Object errorMessage, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.context.request.WebRequest request)
      Method to handle all exception and return as customized response object.
      protected org.springframework.http.ResponseEntity<Object> handleIdAppException​(IdAuthenticationBaseException ex, org.springframework.web.context.request.WebRequest request)
      Method to handle and customize the response.
      • Methods inherited from class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler

        handleAsyncRequestTimeoutException, handleBindException, handleConversionNotSupported, handleException, handleHttpMediaTypeNotAcceptable, handleHttpMediaTypeNotSupported, handleHttpMessageNotReadable, handleHttpMessageNotWritable, handleHttpRequestMethodNotSupported, handleMethodArgumentNotValid, handleMissingPathVariable, handleMissingServletRequestParameter, handleMissingServletRequestPart, handleNoHandlerFoundException, handleServletRequestBindingException, handleTypeMismatch
    • Constructor Detail

      • IdAuthExceptionHandler

        public IdAuthExceptionHandler()
        Instantiates a new id auth exception handler.
    • Method Detail

      • handleAllExceptions

        @ExceptionHandler(java.lang.Exception.class)
        protected org.springframework.http.ResponseEntity<Object> handleAllExceptions​(Exception ex,
                                                                                      org.springframework.web.context.request.WebRequest request)
        Handle all exceptions.
        Parameters:
        ex - the ex
        request - the request
        Returns:
        the response entity
      • handleExceptionInternal

        protected org.springframework.http.ResponseEntity<Object> handleExceptionInternal​(Exception ex,
                                                                                          @Nullable
                                                                                          Object errorMessage,
                                                                                          org.springframework.http.HttpHeaders headers,
                                                                                          org.springframework.http.HttpStatus status,
                                                                                          org.springframework.web.context.request.WebRequest request)
        Method to handle all exception and return as customized response object.
        Overrides:
        handleExceptionInternal in class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
        Parameters:
        ex - Exception
        errorMessage - List of error messages
        headers - Http headers
        status - Http status
        request - Web request
        Returns:
        Customized response object
        See Also:
        ResponseEntityExceptionHandler.handleExceptionInternal(java.lang.Exception, java.lang.Object, org.springframework.http.HttpHeaders, org.springframework.http.HttpStatus, org.springframework.web.context.request.WebRequest)
      • buildExceptionResponse

        public static Object buildExceptionResponse​(Exception ex,
                                                    javax.servlet.http.HttpServletRequest request)
        Constructs exception response body for all exceptions.
        Parameters:
        ex - the exception occurred
        request - the request
        Returns:
        Object .
      • buildExceptionResponse

        public static Object buildExceptionResponse​(Exception ex,
                                                    javax.servlet.http.HttpServletRequest request,
                                                    List<AuthError> errors)