Package org.dellroad.stuff.validation
Class SelfValidationException
java.lang.Object
java.lang.Throwable
java.lang.Exception
org.dellroad.stuff.validation.SelfValidationException
- All Implemented Interfaces:
Serializable
Exception that can be thrown by
SelfValidating.checkValid(jakarta.validation.ConstraintValidatorContext)
.
Instances will be automatically caught and converted into a constraint violation using the exception's message if any, otherwise the default message.
Note that the message
constructor parameter is a JSR 303 template string; to provide a plain text string,
use SelfValidationException.escapeTemplate()
or SelfValidationException.plain()
.
- See Also:
-
Constructor Summary
ConstructorDescriptionConstructor.SelfValidationException
(String message) Constructor.SelfValidationException
(String message, Throwable cause) Constructor.SelfValidationException
(Throwable cause) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic String
escapeTemplate
(String message) Escape any special characters in the given literal string, returning an equivalent JSR 303 message template.static SelfValidationException
Build aSelfValidationException
with the given plain text message.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
SelfValidationException
public SelfValidationException()Constructor. -
SelfValidationException
Constructor.- Parameters:
message
- validation error message template
-
SelfValidationException
Constructor.- Parameters:
cause
- underlying cause of this exception
-
SelfValidationException
Constructor.- Parameters:
message
- validation error message templatecause
- underlying cause of this exception
-
-
Method Details
-
plain
Build aSelfValidationException
with the given plain text message.- Parameters:
message
- plain message string, or null for none- Returns:
- new
SelfValidationException
- See Also:
-
escapeTemplate
Escape any special characters in the given literal string, returning an equivalent JSR 303 message template.- Parameters:
message
- plain message string- Returns:
- JSR 303 message template
- Throws:
IllegalArgumentException
- ifmessage
is null
-