refined exception messages; added unit tests for custom array types
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.core.convert;
|
||||
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* Exception to be thrown when an actual type conversion attempt fails.
|
||||
*
|
||||
@@ -40,8 +42,8 @@ public final class ConversionFailedException extends ConversionException {
|
||||
* @param cause the cause of the conversion failure
|
||||
*/
|
||||
public ConversionFailedException(TypeDescriptor sourceType, TypeDescriptor targetType, Object value, Throwable cause) {
|
||||
super("Unable to convert value \"" + value + "\" from type '" + sourceType.getName() +
|
||||
"' to type '" + targetType.getName() + "'", cause);
|
||||
super("Unable to convert value \"" + ObjectUtils.nullSafeToString(value) + "\" from type '" +
|
||||
sourceType.getName() + "' to type '" + targetType.getName() + "'", cause);
|
||||
this.sourceType = sourceType;
|
||||
this.targetType = targetType;
|
||||
this.value = value;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,7 +36,8 @@ public final class ConverterNotFoundException extends ConversionException {
|
||||
* @param message a descriptive message
|
||||
*/
|
||||
public ConverterNotFoundException(TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
super("No converter found capable of converting from [" + sourceType.getName() + "] to [" + targetType.getName() + "]");
|
||||
super("No converter found capable of converting from '" + sourceType.getName() +
|
||||
"' to '" + targetType.getName() + "'");
|
||||
this.sourceType = sourceType;
|
||||
this.targetType = targetType;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user