ConversionFailedException class final

The conversion error for a value the converter could not handle, such as '12x' for an int.

Also thrown when the converter, or the source itself, gives null for a non-nullable target: convert<int>('') fails this way because a blank string converts to null. The converter's own error is kept in cause.

try {
  DefaultConversionService().convert<int>('12x');
} on ConversionFailedException catch (error) {
  log.warning(error.cause); // the FormatException thrown by the parser
}

Spring (Java):

try {
  new DefaultConversionService().convert("12x", Integer.class);
} catch (ConversionFailedException ex) {
  Throwable cause = ex.getCause();
}
Inheritance

Constructors

ConversionFailedException(Object? value, Type targetType, [Object? cause])
Creates the exception for converting value to targetType, with the converter's error as cause when there was one.

Properties

cause → Object?
The error the converter threw, such as a FormatException; null when the conversion failed because the result was null.
final
hashCode → int
The hash code for this object.
no setterinherited
message → String
What failed, naming the value and the target type.
finalinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
targetType → Type
The requested target type.
final
value → Object?
The source value that could not be converted.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited