public class ConstraintViolationWebErrorHandler extends Object implements WebErrorHandler
WebErrorHandler implementation responsible for handling ConstraintViolationExceptions
from bean validation.| Constructor and Description |
|---|
ConstraintViolationWebErrorHandler() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canHandle(Throwable exception)
Only can handle
ConstraintViolationExceptions that contains at least one
ConstraintViolation. |
HandledException |
handle(Throwable exception)
Handles the given
ConstraintViolationExceptions by extracting the error codes from the message templates
and also, extracting the arguments from ConstraintDescriptors. |
public boolean canHandle(Throwable exception)
ConstraintViolationExceptions that contains at least one
ConstraintViolation.canHandle in interface WebErrorHandlerexception - The exception to examine.true if the exception is a ConstraintViolationException with at least one
violation, false otherwise.@Nonnull public HandledException handle(Throwable exception)
ConstraintViolationExceptions by extracting the error codes from the message templates
and also, extracting the arguments from ConstraintDescriptors.
Size,
can be extracted from the ConstraintDescriptor.getAttributes() method. The
specification of the Bean Validation API demands, that any constraint annotation must define three mandatory
attributes, message, groups and payload. Since these three attributes are not that valuable
as arguments, we're not going to expose them.handle in interface WebErrorHandlerexception - The exception to handle.Copyright © 2018. All rights reserved.