Make EvaluationException more informative

Update EvaluationException to expose the toDetailedString() method as
the exception message. The simple message can now be accessed via the
new getSimpleMessage() method.

Issue: SPR-10938
This commit is contained in:
Phillip Webb
2013-10-25 17:48:31 -07:00
parent 1a3ba79071
commit 014d156f5b
4 changed files with 47 additions and 20 deletions

View File

@@ -87,6 +87,24 @@ public class ExpressionException extends RuntimeException {
}
/**
* Return the exception message. Since Spring 4.0 this method returns the same
* result as {@link #toDetailedString()}.
* @see java.lang.Throwable#getMessage()
*/
@Override
public String getMessage() {
return toDetailedString();
}
/**
* Return the exception simple message without including the expression that caused
* the failure.
*/
public String getSimpleMessage() {
return super.getMessage();
}
public String toDetailedString() {
StringBuilder output = new StringBuilder();
if (this.expressionString!=null) {
@@ -99,7 +117,7 @@ public class ExpressionException extends RuntimeException {
}
output.append(": ");
}
output.append(getMessage());
output.append(getSimpleMessage());
return output.toString();
}