Package dev.hilla.exception
Class EndpointValidationException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- dev.hilla.exception.EndpointException
-
- dev.hilla.exception.EndpointValidationException
-
- All Implemented Interfaces:
Serializable
public class EndpointValidationException extends EndpointException
A validation exception class that is intended to be thrown when any endpoint method receives invalid parameter(s). Behaves similar to theEndpointExceptionand contains additional information about the validation errors.- See Also:
EndpointException, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classEndpointValidationException.ValidationErrorDataA validation error data.
-
Field Summary
-
Fields inherited from class dev.hilla.exception.EndpointException
ERROR_MESSAGE_FIELD
-
-
Constructor Summary
Constructors Constructor Description EndpointValidationException(EndpointValidationException.ValidationErrorData data)Creates a validation exception from the error data.EndpointValidationException(String message, List<EndpointValidationException.ValidationErrorData> validationErrorData)Creates a validation exception from a error data list.EndpointValidationException(List<EndpointValidationException.ValidationErrorData> validationErrorData)Creates a validation exception from a error data list.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,Object>getSerializationData()Creates a map with the serialization data to be sent to the client when the exception thrown is processed byEndpointController.List<EndpointValidationException.ValidationErrorData>getValidationErrorData()Gets the collection of the data on the validation errors.-
Methods inherited from class dev.hilla.exception.EndpointException
getDetail
-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
-
-
-
Constructor Detail
-
EndpointValidationException
public EndpointValidationException(EndpointValidationException.ValidationErrorData data)
Creates a validation exception from the error data.- Parameters:
data- validation error data, mandatory (cannot benull)
-
EndpointValidationException
public EndpointValidationException(List<EndpointValidationException.ValidationErrorData> validationErrorData)
Creates a validation exception from a error data list.- Parameters:
validationErrorData- A list of validation error data, must not benullor empty.
-
EndpointValidationException
public EndpointValidationException(String message, List<EndpointValidationException.ValidationErrorData> validationErrorData)
Creates a validation exception from a error data list.- Parameters:
message- General error message.validationErrorData- A list of validation error data, must not benullor empty.
-
-
Method Detail
-
getValidationErrorData
public List<EndpointValidationException.ValidationErrorData> getValidationErrorData()
Gets the collection of the data on the validation errors.- Returns:
- the error data
-
getSerializationData
public Map<String,Object> getSerializationData()
Description copied from class:EndpointExceptionCreates a map with the serialization data to be sent to the client when the exception thrown is processed byEndpointController. The following data will be sent to the client:- exception type: either the original exception type or
EndpointException, if no original exception is given - message: non-blank message either from the constructor or from the original exception. If both are blank, none provided.
- detail: detail object serialized to json, if provided in the corresponding constructor
- Overrides:
getSerializationDatain classEndpointException- Returns:
- the data to be sent to the client
- exception type: either the original exception type or
-
-