Package org.bremersee.exception
Class RestApiExceptionMapperImpl
- java.lang.Object
-
- org.bremersee.exception.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 Summary
Constructors Constructor Description RestApiExceptionMapperImpl(RestApiExceptionMapperProperties properties, String applicationName)Instantiates a new rest api exception mapper.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddStackTraceItems(@NotNull org.bremersee.exception.model.RestApiException restApiException, StackTraceElement[] stackTrace)Add stack trace items.org.bremersee.exception.model.RestApiExceptionbuild(@NotNull Throwable exception, String requestPath, Object handler)protected org.bremersee.exception.model.HandlerbuildHandler(Object handler)Build the handler model of the rest ape exception.protected org.bremersee.exception.model.RestApiExceptionbuildRestApiExceptionCause(Throwable cause, @NotNull RestApiExceptionMapperProperties.ExceptionMappingConfig config)Build the cause of a rest api exception.protected StringdetectErrorCode(@NotNull Throwable exception, Object handler, @NotNull RestApiExceptionMapperProperties.ExceptionMappingConfig config)Detect the error code.org.springframework.http.HttpStatusdetectHttpStatus(@NotNull Throwable exception, Object handler)protected @NotNull StringdetectMessage(@NotNull Throwable exception, Object handler, @NotNull RestApiExceptionMapperProperties.ExceptionMappingConfig config)Detect message exception message.protected Class<?>findHandlerClass(Object handler)Find the handler class.protected MethodfindHandlerMethod(Object handler)Find the handler method.List<String>getApiPaths()
-
-
-
Constructor Detail
-
RestApiExceptionMapperImpl
public RestApiExceptionMapperImpl(RestApiExceptionMapperProperties properties, String applicationName)
Instantiates a new rest api exception mapper.- Parameters:
properties- the propertiesapplicationName- the application name
-
-
Method Detail
-
getApiPaths
public List<String> getApiPaths()
- Specified by:
getApiPathsin interfaceorg.bremersee.exception.RestApiExceptionMapper
-
detectHttpStatus
public org.springframework.http.HttpStatus detectHttpStatus(@NotNull @NotNull Throwable exception, @Nullable Object handler)- Specified by:
detectHttpStatusin interfaceorg.bremersee.exception.RestApiExceptionMapper
-
build
public org.bremersee.exception.model.RestApiException build(@NotNull @NotNull Throwable exception, @Nullable String requestPath, @Nullable Object handler)- Specified by:
buildin interfaceorg.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
-
detectMessage
@NotNull protected @NotNull String detectMessage(@NotNull @NotNull Throwable exception, @Nullable Object handler, @NotNull @NotNull RestApiExceptionMapperProperties.ExceptionMappingConfig config)
Detect message exception message.- Parameters:
exception- the exceptionhandler- the handlerconfig- the config- Returns:
- the exception message
-
detectErrorCode
@Nullable protected String detectErrorCode(@NotNull @NotNull Throwable exception, @Nullable Object handler, @NotNull @NotNull RestApiExceptionMapperProperties.ExceptionMappingConfig config)
Detect the error code.- Parameters:
exception- the exceptionhandler- the handlerconfig- the config- Returns:
- the string
-
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 exceptionstackTrace- 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 causeconfig- the config- Returns:
- the rest api exception
-
-