Class HandlerMethodValidationException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.springframework.core.NestedRuntimeException
org.springframework.web.ErrorResponseException
org.springframework.web.server.ResponseStatusException
org.springframework.web.method.annotation.HandlerMethodValidationException
- All Implemented Interfaces:
- Serializable, MethodValidationResult, ErrorResponse
public class HandlerMethodValidationException
extends ResponseStatusException
implements MethodValidationResult
ResponseStatusException that is also MethodValidationResult.
Raised by HandlerMethodValidator in case of method validation errors
on a web controller method.
The ErrorResponseException.getStatusCode() is 400 for input validation errors, and 500
for validation errors on a return value.
- Since:
- 6.1
- Author:
- Rossen Stoyanchev
- See Also:
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic interfaceContract to handle validation results with callbacks by controller method parameter type, withHandlerMethodValidationException.Visitor.other(ParameterValidationResult)serving as the fallthrough.Nested classes/interfaces inherited from interface ErrorResponseErrorResponse.Builder, ErrorResponse.Interceptor
- 
Constructor SummaryConstructorsConstructorDescriptionHandlerMethodValidationException(MethodValidationResult validationResult) HandlerMethodValidationException(MethodValidationResult validationResult, Predicate<MethodParameter> modelAttributePredicate, Predicate<MethodParameter> requestParamPredicate) 
- 
Method SummaryModifier and TypeMethodDescriptionReturn errors from cross-parameter validation.Object[]Return arguments to use along with amessage codeto resolve the problem "detail" for this exception through aMessageSource.Object[]getDetailMessageArguments(MessageSource messageSource, Locale locale) Variant ofErrorResponse.getDetailMessageArguments()that uses the givenMessageSourcefor resolving the message argument values.Return the method to which validation was applied.Return all validation results per method parameter, including bothMethodValidationResult.getValueResults()andMethodValidationResult.getBeanResults().Return the target of the method invocation to which validation was applied.booleanWhether the violations are for a return value.voidProvide aVisitorto handleParameterValidationResults through callback methods organized by controller method parameter type.Methods inherited from class ResponseStatusExceptiongetHeaders, getMessage, getReason, updateAndGetBodyMethods inherited from class ErrorResponseExceptiongetBody, getDetailMessageCode, getStatusCode, setDetail, setInstance, setTitle, setTypeMethods inherited from class NestedRuntimeExceptioncontains, getMostSpecificCause, getRootCauseMethods inherited from class ThrowableaddSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toStringMethods inherited from class Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ErrorResponsegetTitleMessageCode, getTypeMessageCodeMethods inherited from interface MethodValidationResultgetAllErrors, getBeanResults, getValueResults, hasErrors
- 
Constructor Details- 
HandlerMethodValidationException
- 
HandlerMethodValidationExceptionpublic HandlerMethodValidationException(MethodValidationResult validationResult, Predicate<MethodParameter> modelAttributePredicate, Predicate<MethodParameter> requestParamPredicate) 
 
- 
- 
Method Details- 
getDetailMessageArgumentsDescription copied from interface:ErrorResponseVariant ofErrorResponse.getDetailMessageArguments()that uses the givenMessageSourcefor resolving the message argument values.This is useful for example to expand message codes from validation errors. The default implementation delegates to ErrorResponse.getDetailMessageArguments(), ignoring the suppliedMessageSourceandLocale.- Specified by:
- getDetailMessageArgumentsin interface- ErrorResponse
- Parameters:
- messageSource- the- MessageSourceto use for the lookup
- locale- the- Localeto use for the lookup
 
- 
getDetailMessageArgumentsDescription copied from interface:ErrorResponseReturn arguments to use along with amessage codeto resolve the problem "detail" for this exception through aMessageSource. The arguments are expanded into placeholders of the message value, for example, "Invalid content type {0}".- Specified by:
- getDetailMessageArgumentsin interface- ErrorResponse
- Overrides:
- getDetailMessageArgumentsin class- ErrorResponseException
 
- 
getTargetDescription copied from interface:MethodValidationResultReturn the target of the method invocation to which validation was applied.- Specified by:
- getTargetin interface- MethodValidationResult
 
- 
getMethodDescription copied from interface:MethodValidationResultReturn the method to which validation was applied.- Specified by:
- getMethodin interface- MethodValidationResult
 
- 
isForReturnValuepublic boolean isForReturnValue()Description copied from interface:MethodValidationResultWhether the violations are for a return value. If true the violations are from validating a return value. If false the violations are from validating method arguments.- Specified by:
- isForReturnValuein interface- MethodValidationResult
 
- 
getParameterValidationResultsDescription copied from interface:MethodValidationResultReturn all validation results per method parameter, including bothMethodValidationResult.getValueResults()andMethodValidationResult.getBeanResults().Use MethodValidationResult.getCrossParameterValidationResults()for access to errors from cross-parameter validation.- Specified by:
- getParameterValidationResultsin interface- MethodValidationResult
- See Also:
 
- 
getCrossParameterValidationResultsDescription copied from interface:MethodValidationResultReturn errors from cross-parameter validation.- Specified by:
- getCrossParameterValidationResultsin interface- MethodValidationResult
 
- 
visitResultsProvide aVisitorto handleParameterValidationResults through callback methods organized by controller method parameter type.
 
-