Browse Source

change from string compare to code compare for Spel exceptions

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@1356 50f2f4bb-b051-0410-bef5-90022cba6387
pull/1/head
Andy Clement 17 years ago
parent
commit
85b193a3a2
  1. 19
      org.springframework.context/src/main/java/org/springframework/ui/binding/support/GenericBinder.java

19
org.springframework.context/src/main/java/org/springframework/ui/binding/support/GenericBinder.java

@ -39,6 +39,8 @@ import org.springframework.expression.EvaluationException; @@ -39,6 +39,8 @@ import org.springframework.expression.EvaluationException;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionException;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.SpelEvaluationException;
import org.springframework.expression.spel.SpelMessage;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParserConfiguration;
import org.springframework.expression.spel.support.StandardEvaluationContext;
@ -479,14 +481,15 @@ public class GenericBinder implements Binder { @@ -479,14 +481,15 @@ public class GenericBinder implements Binder {
}
public String getErrorCode() {
if (e.getMessage().startsWith("EL1034E")) {
return "typeConversionFailure";
} else if (e.getMessage().startsWith("EL1008E")) {
return "propertyNotFound";
} else {
// TODO return more specific code based on underlying EvaluationException error code
return "couldNotSetValue";
}
SpelMessage spelCode = ((SpelEvaluationException)e).getMessageCode();
if (spelCode==SpelMessage.EXCEPTION_DURING_PROPERTY_WRITE) {
return "typeConversionFailure";
} else if (spelCode==SpelMessage.PROPERTY_OR_FIELD_NOT_READABLE) {
return "propertyNotFound";
} else {
// TODO return more specific code based on underlying EvaluationException error code
return "couldNotSetValue";
}
}
public Throwable getErrorCause() {

Loading…
Cancel
Save