提交 6875df28 编写于 作者: A Andy Clement

change from string compare to code compare for Spel exceptions

上级 69e48828
...@@ -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.Expression;
import org.springframework.expression.ExpressionException; import org.springframework.expression.ExpressionException;
import org.springframework.expression.ExpressionParser; 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.SpelExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParserConfiguration; import org.springframework.expression.spel.standard.SpelExpressionParserConfiguration;
import org.springframework.expression.spel.support.StandardEvaluationContext; 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() { public String getErrorCode() {
if (e.getMessage().startsWith("EL1034E")) { SpelMessage spelCode = ((SpelEvaluationException)e).getMessageCode();
return "typeConversionFailure"; if (spelCode==SpelMessage.EXCEPTION_DURING_PROPERTY_WRITE) {
} else if (e.getMessage().startsWith("EL1008E")) { return "typeConversionFailure";
return "propertyNotFound"; } else if (spelCode==SpelMessage.PROPERTY_OR_FIELD_NOT_READABLE) {
} else { return "propertyNotFound";
// TODO return more specific code based on underlying EvaluationException error code } else {
return "couldNotSetValue"; // TODO return more specific code based on underlying EvaluationException error code
} return "couldNotSetValue";
}
} }
public Throwable getErrorCause() { public Throwable getErrorCause() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册