From 4a90266f8e62c1072011b8beb595d17f0d704aee Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 7 Jan 2010 13:27:40 +0000 Subject: [PATCH] expose offending value through public "getValue()" method (SPR-6629) --- .../convert/ConversionFailedException.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/org.springframework.core/src/main/java/org/springframework/core/convert/ConversionFailedException.java b/org.springframework.core/src/main/java/org/springframework/core/convert/ConversionFailedException.java index 47a011db16..2b91c588df 100644 --- a/org.springframework.core/src/main/java/org/springframework/core/convert/ConversionFailedException.java +++ b/org.springframework.core/src/main/java/org/springframework/core/convert/ConversionFailedException.java @@ -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. @@ -17,7 +17,7 @@ package org.springframework.core.convert; /** - * Thrown when an attempt to execute a type conversion fails. + * Exception to be thrown when an actual type conversion attempt fails. * * @author Keith Donald * @author Juergen Hoeller @@ -29,12 +29,14 @@ public final class ConversionFailedException extends ConversionException { private final TypeDescriptor targetType; + private final Object value; + /** * Create a new conversion exception. - * @param value the value we tried to convert * @param sourceType the value's original type * @param targetType the value's target type + * @param value the value we tried to convert * @param cause the cause of the conversion failure */ public ConversionFailedException(TypeDescriptor sourceType, TypeDescriptor targetType, Object value, Throwable cause) { @@ -42,6 +44,7 @@ public final class ConversionFailedException extends ConversionException { "' to type '" + targetType.getName() + "'", cause); this.sourceType = sourceType; this.targetType = targetType; + this.value = value; } @@ -53,10 +56,17 @@ public final class ConversionFailedException extends ConversionException { } /** - * Returns the target type we tried to convert the value to. + * Return the target type we tried to convert the value to. */ public TypeDescriptor getTargetType() { return this.targetType; } + /** + * Return the offending value. + */ + public Object getValue() { + return this.value; + } + }