Class RuntimeExceptionAdvisor
java.lang.Object
com.broadleafcommerce.common.error.validation.web.RuntimeExceptionAdvisor
@RestControllerAdvice(annotations=org.springframework.web.bind.annotation.ResponseBody.class)
public class RuntimeExceptionAdvisor
extends Object
Exception advisor with a handler that handles uncaught runtime exceptions by logging them and
returning an error response.
Note, this advisor is intentionally un-ordered to ensure it runs last.
- Author:
- Nick Crum (ncrum)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<ApiError>
handleRuntimeException
(RuntimeException ex, org.springframework.web.context.request.WebRequest request) Handles uncaught runtime exceptions by logging them and returning anApiError
.protected void
-
Constructor Details
-
RuntimeExceptionAdvisor
public RuntimeExceptionAdvisor()
-
-
Method Details
-
handleRuntimeException
@ExceptionHandler(java.lang.RuntimeException.class) public org.springframework.http.ResponseEntity<ApiError> handleRuntimeException(RuntimeException ex, org.springframework.web.context.request.WebRequest request) Handles uncaught runtime exceptions by logging them and returning anApiError
.- Parameters:
ex
- the exceptionrequest
- the web request- Returns:
- the api error
-
logError
-