Package io.avaje.http.api
Class ValidationException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
java.lang.IllegalArgumentException
io.avaje.http.api.ValidationException
- All Implemented Interfaces:
Serializable
public class ValidationException extends IllegalArgumentException
Exception used with Validator.
Typically this is used when validating a bean populated by request body content.
Generally this exception type is registered with an exception handler and configured to return a 422 or 400 http status response with the errors as a map of fields to error message.
- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description ValidationException(int status, String message)Create with a status and message.ValidationException(int status, String message, Map<String,Object> errors)Create with a status message and errors.ValidationException(String message)Create with a message. -
Method Summary
Modifier and Type Method Description Map<String,Object>getErrors()Return the errors typically as a map of field to error message.intgetStatus()Return the suggested HTTP status to use in the response.voidsetErrors(Map<String,Object> errors)Set the errors.voidsetStatus(int status)Set the suggested HTTP status to use in the response.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
ValidationException
Create with a message. -
ValidationException
Create with a status and message. -
ValidationException
Create with a status message and errors.
-
-
Method Details
-
getStatus
Return the suggested HTTP status to use in the response. -
setStatus
Set the suggested HTTP status to use in the response. -
getErrors
Return the errors typically as a map of field to error message. -
setErrors
Set the errors.
-