Backported exception message refinements from 4.2.x

This commit is contained in:
Juergen Hoeller
2015-11-30 12:24:38 +01:00
parent 6c4f0a4d9f
commit a730b6e1aa
3 changed files with 15 additions and 10 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2015 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.
@@ -43,7 +43,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("Failed to convert from type " + sourceType + " to type " + targetType + " for value '" + ObjectUtils.nullSafeToString(value) + "'", cause);
super("Failed to convert from type [" + sourceType + "] to type [" + targetType +
"] for value '" + ObjectUtils.nullSafeToString(value) + "'", cause);
this.sourceType = sourceType;
this.targetType = targetType;
this.value = value;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2015 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.
@@ -17,9 +17,11 @@
package org.springframework.core.convert;
/**
* Thrown when a suitable converter could not be found in a conversion service.
* Exception to be thrown when a suitable converter could not be found
* in a given conversion service.
*
* @author Keith Donald
* @author Juergen Hoeller
* @since 3.0
*/
@SuppressWarnings("serial")
@@ -36,21 +38,21 @@ public final class ConverterNotFoundException extends ConversionException {
* @param targetType the target type requested to convert to
*/
public ConverterNotFoundException(TypeDescriptor sourceType, TypeDescriptor targetType) {
super("No converter found capable of converting from type " + sourceType + " to type " + targetType);
super("No converter found capable of converting from type [" + sourceType + "] to type [" + targetType + "]");
this.sourceType = sourceType;
this.targetType = targetType;
}
/**
* Returns the source type that was requested to convert from.
* Return the source type that was requested to convert from.
*/
public TypeDescriptor getSourceType() {
return this.sourceType;
}
/**
* Returns the target type that was requested to convert to.
* Return the target type that was requested to convert to.
*/
public TypeDescriptor getTargetType() {
return this.targetType;