diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/ConversionException.java b/spring-binding/src/main/java/org/springframework/binding/convert/ConversionException.java index 4a63bd37..77f1cf67 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/ConversionException.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/ConversionException.java @@ -37,18 +37,6 @@ public class ConversionException extends RuntimeException { */ private transient Object value; - /** - * Creates a new conversion exception. - * @param value the value we tried to convert - * @param targetClass the target type - */ - public ConversionException(Object value, Class targetClass) { - super("Unable to convert value '" + value + "' of type '" + (value != null ? value.getClass().getName() : null) - + "' to class '" + targetClass.getName() + "'"); - this.value = value; - this.targetClass = targetClass; - } - /** * Creates a new conversion exception. * @param value the value we tried to convert @@ -64,13 +52,14 @@ public class ConversionException extends RuntimeException { /** * Creates a new conversion exception. + * @param sourceClass the source type * @param value the value we tried to convert * @param targetClass the target type * @param message a descriptive message - * @param cause underlying cause of this exception */ - public ConversionException(Object value, Class targetClass, String message, Throwable cause) { + public ConversionException(Class sourceClass, Object value, Class targetClass, String message, Throwable cause) { super(message, cause); + this.sourceClass = sourceClass; this.value = value; this.targetClass = targetClass; } @@ -84,33 +73,6 @@ public class ConversionException extends RuntimeException { public ConversionException(Class sourceClass, Class targetClass, String message) { super(message); this.sourceClass = sourceClass; - this.value = null; // not available - this.targetClass = targetClass; - } - - /** - * Creates a new conversion exception. - * @param sourceClass the source type - * @param message a descriptive message - */ - public ConversionException(Class sourceClass, String message) { - super(message); - this.sourceClass = sourceClass; - this.value = null; // not available - this.targetClass = null; // not available - } - - /** - * Creates a new conversion exception. - * @param sourceClass the source type - * @param value the value we tried to convert - * @param targetClass the target type - * @param message a descriptive message - */ - public ConversionException(Class sourceClass, Object value, Class targetClass, String message) { - super(message); - this.sourceClass = sourceClass; - this.value = value; this.targetClass = targetClass; } @@ -121,6 +83,13 @@ public class ConversionException extends RuntimeException { return sourceClass; } + /** + * Returns the target type. + */ + public Class getTargetClass() { + return targetClass; + } + /** * Returns the value we tried to convert. */ @@ -128,10 +97,4 @@ public class ConversionException extends RuntimeException { return value; } - /** - * Returns the target type. - */ - public Class getTargetClass() { - return targetClass; - } } \ No newline at end of file diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/service/StaticConversionExecutor.java b/spring-binding/src/main/java/org/springframework/binding/convert/service/StaticConversionExecutor.java index 28acff05..4c3597e5 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/service/StaticConversionExecutor.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/service/StaticConversionExecutor.java @@ -97,7 +97,7 @@ class StaticConversionExecutor implements ConversionExecutor { } if (source != null && !sourceClass.isInstance(source)) { throw new ConversionException(getSourceClass(), source, getTargetClass(), "Source object '" + source - + "' is expected to be an instance of " + getSourceClass()); + + "' is expected to be an instance of " + getSourceClass(), null); } return converter.convert(source, targetClass, context); }