Class MethodArgumentNotValidResponseEnricher

java.lang.Object
org.hawaiiframework.web.exception.MethodArgumentNotValidResponseEnricher
All Implemented Interfaces:
ErrorResponseEnricher

public class MethodArgumentNotValidResponseEnricher extends Object implements ErrorResponseEnricher
This enricher adds validation errors to the error response resource.
Since:
2.0.0
  • Constructor Details

    • MethodArgumentNotValidResponseEnricher

      public MethodArgumentNotValidResponseEnricher(ModelConverter<org.springframework.validation.ObjectError,ValidationErrorResource> objectErrorResourceAssembler)
      The constructor.
  • Method Details

    • doEnrich

      public void doEnrich(ErrorResponseResource errorResponseResource, Throwable throwable, org.springframework.web.context.request.WebRequest request, org.springframework.http.HttpStatus httpStatus)
      Performs the enrichment of the error response resource.

      Note that the http status is a given, it is assumed to be determined in the exception handler.

      NOTE: This enricher only applies if throwable is a MethodArgumentNotValidException and #errorResponseResource is a MethodArgumentNotValidResponseResource.

      Specified by:
      doEnrich in interface ErrorResponseEnricher
      Parameters:
      errorResponseResource - the error response resource
      throwable - the exception that was raised
      request - the original web request
      httpStatus - the http status that will be returned