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 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 an ApiError.
      Parameters:
      ex - the exception
      request - the web request
      Returns:
      the api error
    • logError

      protected void logError(Throwable ex, org.springframework.web.context.request.WebRequest request)