Class JaxrsValidationException
- All Implemented Interfaces:
Serializable
JaxrsException to use Kiwi's ErrorMessage.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe status code for all instances of this exception. -
Constructor Summary
ConstructorsConstructorDescriptionNew instance with given item ID and error messages.JaxrsValidationException(String itemId, Set<? extends jakarta.validation.ConstraintViolation<?>> violations) New instance with given item ID and constraint violations.JaxrsValidationException(String itemId, Set<? extends jakarta.validation.ConstraintViolation<?>> violations, Map<String, String> propertyPathMappings) New instance with given item ID, constraint violations, and a map containing entries whose keys are the property path of theConstraintViolationand values are the field/property name that should be used in place of the property path.JaxrsValidationException(List<ErrorMessage> errorMessages) New instance with givenErrorMessageobjects. -
Method Summary
Modifier and TypeMethodDescriptionstatic JaxrsValidationExceptionofErrorMessages(List<ErrorMessage> errorMessages) Factory method to create validation exception from a non-null list ofErrorMessage.Methods inherited from class org.kiwiproject.jaxrs.exception.JaxrsException
buildJaxrsException, getErrorCode, getErrors, getOtherData, getRollUpStatus, getStatusCode, setErrors, setOtherDataMethods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Field Details
-
CODE
public static final int CODEThe status code for all instances of this exception.- See Also:
-
-
Constructor Details
-
JaxrsValidationException
New instance with given item ID and error messages.Each map contained in
errorMessageMapsmust have entries with at least two keys:ErrorMessage.KEY_FIELD_NAMEandErrorMessage.KEY_MESSAGE. In other words, the maps should contain an entry whose key isErrorMessage.KEY_FIELD_NAMEand another entry whose key isErrorMessage.KEY_MESSAGE. Any other entries are ignored. The value of these two entries become the field name and message in the resultingErrorMessageobjects.- Parameters:
itemId- the unique ID of the item that caused this errorerrorMessageMaps- a list containing maps containing
-
JaxrsValidationException
public JaxrsValidationException(String itemId, Set<? extends jakarta.validation.ConstraintViolation<?>> violations) New instance with given item ID and constraint violations.- Parameters:
itemId- the unique ID of the item that caused this errorviolations- the constraint violations to transform intoErrorMessageobjects
-
JaxrsValidationException
public JaxrsValidationException(String itemId, Set<? extends jakarta.validation.ConstraintViolation<?>> violations, Map<String, String> propertyPathMappings) New instance with given item ID, constraint violations, and a map containing entries whose keys are the property path of theConstraintViolationand values are the field/property name that should be used in place of the property path.For example,
propertyPathMappingsmight contain an entry with key "firstName" and value "First Name". In the resulting instance, the correspondingErrorMessageobject contained in the list returned byJaxrsException.getErrors()will have "First Name" as the field name.- Parameters:
itemId- the unique ID of the item that caused this errorviolations- the constraint violations to transform intoErrorMessageobjectspropertyPathMappings- mappings from property path of aConstraintViolationto the field name to use in theErrorMessageobjects
-
JaxrsValidationException
New instance with givenErrorMessageobjects.It is assumed but not checked that the
ErrorMessageobjects are due to 422 errors. Therefore, it is possible to instantiate an instance with errors that have some other status code.- Parameters:
errorMessages- non-null list of error messages
-
-
Method Details
-
ofErrorMessages
Factory method to create validation exception from a non-null list ofErrorMessage.- Parameters:
errorMessages- non-null list of error messages- Returns:
- a new
JaxrsValidationExceptioninstance - See Also:
-