add EventAttributeELResolver
improved invalid variable ex message
This commit is contained in:
@@ -25,6 +25,7 @@ import org.springframework.core.style.ToStringCreator;
|
||||
public class EvaluationAttempt {
|
||||
|
||||
private Expression expression;
|
||||
|
||||
private Object context;
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,19 +15,17 @@
|
||||
*/
|
||||
package org.springframework.binding.expression;
|
||||
|
||||
import org.springframework.core.NestedRuntimeException;
|
||||
|
||||
/**
|
||||
* Indicates an expression evaluation failed.
|
||||
*
|
||||
* @author Keith Donald
|
||||
*/
|
||||
public class EvaluationException extends NestedRuntimeException {
|
||||
public class EvaluationException extends RuntimeException {
|
||||
|
||||
/**
|
||||
* The evaluation attempt that failed. Transient because an EvaluationAttempt is not serializable.
|
||||
*/
|
||||
private transient EvaluationAttempt evaluationAttempt;
|
||||
private EvaluationAttempt evaluationAttempt;
|
||||
|
||||
/**
|
||||
* Creates a new evaluation exception.
|
||||
@@ -35,7 +33,17 @@ public class EvaluationException extends NestedRuntimeException {
|
||||
* @param cause the underlying cause of this exception
|
||||
*/
|
||||
public EvaluationException(EvaluationAttempt evaluationAttempt, Throwable cause) {
|
||||
super(evaluationAttempt + " failed - make sure the expression is evaluatable in the context provided", cause);
|
||||
this(evaluationAttempt, evaluationAttempt
|
||||
+ " failed - make sure the expression is evaluatable in the context provided", cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new evaluation exception.
|
||||
* @param evaluationAttempt the evaluation attempt that failed
|
||||
* @param cause the underlying cause of this exception
|
||||
*/
|
||||
public EvaluationException(EvaluationAttempt evaluationAttempt, String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.evaluationAttempt = evaluationAttempt;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,9 @@ public class ELExpression implements Expression {
|
||||
try {
|
||||
Object result = valueExpression.getValue(ctx);
|
||||
if (result == null && !ctx.isPropertyResolved()) {
|
||||
throw new EvaluationException(new EvaluationAttempt(this, context), null);
|
||||
EvaluationAttempt attempt = new EvaluationAttempt(this, context);
|
||||
throw new EvaluationException(attempt, attempt
|
||||
+ " failed: the expression path did not resolve--is the base variable incorrect?", null);
|
||||
}
|
||||
return result;
|
||||
} catch (javax.el.PropertyNotFoundException e) {
|
||||
@@ -59,7 +61,9 @@ public class ELExpression implements Expression {
|
||||
try {
|
||||
valueExpression.setValue(ctx, value);
|
||||
if (!ctx.isPropertyResolved()) {
|
||||
throw new EvaluationException(new SetValueAttempt(this, context, value), null);
|
||||
SetValueAttempt attempt = new SetValueAttempt(this, context, value);
|
||||
throw new EvaluationException(attempt, attempt
|
||||
+ " failed: the expression path did not resolve--is the base variable incorrect?", null);
|
||||
}
|
||||
} catch (javax.el.PropertyNotFoundException e) {
|
||||
throw new PropertyNotFoundException(new EvaluationAttempt(this, context), e);
|
||||
|
||||
Reference in New Issue
Block a user