public class ValidationException extends IllegalArgumentException
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.
| Constructor and 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.
|
| Modifier and Type | Method and Description |
|---|---|
Map<String,Object> |
getErrors()
Return the errors typically as a map of field to error message.
|
int |
getStatus()
Return the suggested HTTP status to use in the response.
|
void |
setErrors(Map<String,Object> errors)
Set the errors.
|
void |
setStatus(int status)
Set the suggested HTTP status to use in the response.
|
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toStringpublic ValidationException(String message)
public ValidationException(int status, String message)
public ValidationException(int status, String message, Map<String,Object> errors)
public int getStatus()
public void setStatus(int status)
public Map<String,Object> getErrors()
Copyright © 2019. All rights reserved.