ConversionException class sealed
The error a conversion service throws when a value cannot be turned into the requested type.
Catch it where a value comes from outside and a bad one should not be
fatal, such as a query parameter or a line of an import file. When it
happens while beans are created (a bad @Value), the start fails.
It is sealed: every conversion error is either a
ConversionFailedException (a converter exists but the value is bad)
or a ConverterNotFoundException (nothing converts to that type).
// A page size typed by a user: fall back instead of failing.
int pageSize(String input) {
try {
return conversionService.convert<int>(input);
} on ConversionException catch (error) {
log.warn(error.message);
return 20;
}
}
Spring (Java):
try {
conversionService.convert("abc", Integer.class);
} catch (ConversionException ex) {
log.warn(ex.getMessage());
}
- Implemented types
Properties
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited