Class RestApiExceptionMapperImpl

  • All Implemented Interfaces:
    org.bremersee.exception.RestApiExceptionMapper

    @Validated
    public class RestApiExceptionMapperImpl
    extends Object
    implements org.bremersee.exception.RestApiExceptionMapper
    The default implementation of a rest api exception mapper.
    Author:
    Christian Bremer
    • Constructor Detail

      • RestApiExceptionMapperImpl

        public RestApiExceptionMapperImpl​(RestApiExceptionMapperProperties properties,
                                          String applicationName)
        Instantiates a new rest api exception mapper.
        Parameters:
        properties - the properties
        applicationName - the application name
    • Method Detail

      • getApiPaths

        public List<String> getApiPaths()
        Specified by:
        getApiPaths in interface org.bremersee.exception.RestApiExceptionMapper
      • detectHttpStatus

        public org.springframework.http.HttpStatus detectHttpStatus​(@NotNull
                                                                    @NotNull Throwable exception,
                                                                    @Nullable
                                                                    Object handler)
        Specified by:
        detectHttpStatus in interface org.bremersee.exception.RestApiExceptionMapper
      • build

        public org.bremersee.exception.model.RestApiException build​(@NotNull
                                                                    @NotNull Throwable exception,
                                                                    @Nullable
                                                                    String requestPath,
                                                                    @Nullable
                                                                    Object handler)
        Specified by:
        build in interface org.bremersee.exception.RestApiExceptionMapper
      • findHandlerClass

        @Nullable
        protected Class<?> findHandlerClass​(@Nullable
                                            Object handler)
        Find the handler class.
        Parameters:
        handler - the handler
        Returns:
        the class
      • findHandlerMethod

        @Nullable
        protected Method findHandlerMethod​(Object handler)
        Find the handler method.
        Parameters:
        handler - the handler
        Returns:
        the method
      • buildHandler

        @Nullable
        protected org.bremersee.exception.model.Handler buildHandler​(@Nullable
                                                                     Object handler)
        Build the handler model of the rest ape exception.
        Parameters:
        handler - the handler
        Returns:
        the handler model
      • addStackTraceItems

        protected void addStackTraceItems​(@NotNull
                                          @NotNull org.bremersee.exception.model.RestApiException restApiException,
                                          @Nullable
                                          StackTraceElement[] stackTrace)
        Add stack trace items.
        Parameters:
        restApiException - the rest api exception
        stackTrace - the stack trace
      • buildRestApiExceptionCause

        @Nullable
        protected org.bremersee.exception.model.RestApiException buildRestApiExceptionCause​(@Nullable
                                                                                            Throwable cause,
                                                                                            @NotNull
                                                                                            @NotNull RestApiExceptionMapperProperties.ExceptionMappingConfig config)
        Build the cause of a rest api exception.
        Parameters:
        cause - the cause
        config - the config
        Returns:
        the rest api exception