Class ValidationException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
java.lang.IllegalArgumentException
com.winterhavenmc.library.messagebuilder.validation.ValidationException
- All Implemented Interfaces:
Serializable
Thrown to indicate that a parameter validation has failed.
This exception supports localized error messages using the provided
ErrorMessageKey
and Parameter
, and is typically thrown
via static methods in Validator
.
Unlike IllegalArgumentException
, this class is designed specifically
to support structured, translatable messages in a plugin context.
The message string is generated using Validator.formatMessage(ErrorMessageKey, Parameter)
,
and may vary depending on the configured locale.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionValidationException
(ErrorMessageKey errorMessageKey, Parameter parameter) Constructs a newValidationException
with the specifiedErrorMessageKey
andParameter
describing the failed validation. -
Method Summary
Modifier and TypeMethodDescriptionReturns the localized message for this validation exception.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
ValidationException
Constructs a newValidationException
with the specifiedErrorMessageKey
andParameter
describing the failed validation.The exception message is immediately formatted using the current locale returned by
ValidationContext.getLocale()
.- Parameters:
errorMessageKey
- a structured key identifying the error message templateparameter
- the parameter that failed validation
-
-
Method Details
-
getMessage
Returns the localized message for this validation exception. The message is re-formatted on each call to reflect any changes in the active locale.- Overrides:
getMessage
in classThrowable
- Returns:
- the localized validation error message
-