change from string compare to code compare for Spel exceptions
This commit is contained in:
parent
69e48828cc
commit
6875df28d9
|
|
@ -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 {
|
||||||
}
|
}
|
||||||
|
|
||||||
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() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue