Search in sources :

Example 16 with ELException

use of jakarta.el.ELException in project tomcat by apache.

the class JspMethodExpression method getMethodReference.

@Override
public MethodReference getMethodReference(ELContext context) {
    context.notifyBeforeEvaluation(getExpressionString());
    try {
        MethodReference result = this.target.getMethodReference(context);
        context.notifyAfterEvaluation(getExpressionString());
        return result;
    } catch (MethodNotFoundException e) {
        if (e instanceof JspMethodNotFoundException) {
            throw e;
        }
        throw new JspMethodNotFoundException(this.mark, e);
    } catch (PropertyNotFoundException e) {
        if (e instanceof JspPropertyNotFoundException) {
            throw e;
        }
        throw new JspPropertyNotFoundException(this.mark, e);
    } catch (ELException e) {
        if (e instanceof JspELException) {
            throw e;
        }
        throw new JspELException(this.mark, e);
    }
}
Also used : PropertyNotFoundException(jakarta.el.PropertyNotFoundException) MethodReference(jakarta.el.MethodReference) ELException(jakarta.el.ELException) MethodNotFoundException(jakarta.el.MethodNotFoundException)

Example 17 with ELException

use of jakarta.el.ELException in project tomcat by apache.

the class JspMethodExpression method getMethodInfo.

@Override
public MethodInfo getMethodInfo(ELContext context) throws NullPointerException, PropertyNotFoundException, MethodNotFoundException, ELException {
    context.notifyBeforeEvaluation(getExpressionString());
    try {
        MethodInfo result = this.target.getMethodInfo(context);
        context.notifyAfterEvaluation(getExpressionString());
        return result;
    } catch (MethodNotFoundException e) {
        if (e instanceof JspMethodNotFoundException) {
            throw e;
        }
        throw new JspMethodNotFoundException(this.mark, e);
    } catch (PropertyNotFoundException e) {
        if (e instanceof JspPropertyNotFoundException) {
            throw e;
        }
        throw new JspPropertyNotFoundException(this.mark, e);
    } catch (ELException e) {
        if (e instanceof JspELException) {
            throw e;
        }
        throw new JspELException(this.mark, e);
    }
}
Also used : PropertyNotFoundException(jakarta.el.PropertyNotFoundException) MethodInfo(jakarta.el.MethodInfo) ELException(jakarta.el.ELException) MethodNotFoundException(jakarta.el.MethodNotFoundException)

Example 18 with ELException

use of jakarta.el.ELException in project tomcat by apache.

the class TestELParser method doTestParser.

private void doTestParser(String input, String expectedResult, String expectedBuilderOutput) throws JasperException {
    ELException elException = null;
    String elResult = null;
    // Don't try and evaluate expressions that depend on variables or functions
    if (expectedResult != null) {
        try {
            ELManager manager = new ELManager();
            ELContext context = manager.getELContext();
            ExpressionFactory factory = ELManager.getExpressionFactory();
            ValueExpression ve = factory.createValueExpression(context, input, String.class);
            elResult = ve.getValue(context).toString();
            Assert.assertEquals(expectedResult, elResult);
        } catch (ELException ele) {
            elException = ele;
        }
    }
    Nodes nodes = null;
    try {
        nodes = ELParser.parse(input, false);
        Assert.assertNull(elException);
    } catch (IllegalArgumentException iae) {
        Assert.assertNotNull(elResult, elException);
        // Not strictly true but enables us to report both
        iae.initCause(elException);
        throw iae;
    }
    TextBuilder textBuilder = new TextBuilder(false);
    nodes.visit(textBuilder);
    Assert.assertEquals(expectedBuilderOutput, textBuilder.getText());
}
Also used : ELContext(jakarta.el.ELContext) TextBuilder(org.apache.jasper.compiler.ELParser.TextBuilder) ExpressionFactory(jakarta.el.ExpressionFactory) ValueExpression(jakarta.el.ValueExpression) ELManager(jakarta.el.ELManager) ELException(jakarta.el.ELException) Nodes(org.apache.jasper.compiler.ELNode.Nodes)

Aggregations

ELException (jakarta.el.ELException)18 ValueExpression (jakarta.el.ValueExpression)6 LambdaExpression (jakarta.el.LambdaExpression)4 PropertyNotFoundException (jakarta.el.PropertyNotFoundException)4 Method (java.lang.reflect.Method)4 Test (org.junit.Test)4 ELContext (jakarta.el.ELContext)3 ExpressionFactory (jakarta.el.ExpressionFactory)3 MethodNotFoundException (jakarta.el.MethodNotFoundException)3 VariableMapper (jakarta.el.VariableMapper)3 ELClass (jakarta.el.ELClass)2 FunctionMapper (jakarta.el.FunctionMapper)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ELContextImpl (org.apache.jasper.el.ELContextImpl)2 ELManager (jakarta.el.ELManager)1 ELResolver (jakarta.el.ELResolver)1 MethodExpression (jakarta.el.MethodExpression)1 MethodInfo (jakarta.el.MethodInfo)1 MethodReference (jakarta.el.MethodReference)1 PropertyEditor (java.beans.PropertyEditor)1