I'm trying to execute a function dynamically using JEXL 2.1.1 and a Script. The function is defined by me and it throws a custom error.

It seems like JEXL catches the exception, but does not propagate it, only shows it. I really need to know when the exception occurs, because it is a critical error and I want my program to exit.

I tried setting the silent mode to false. I understand that in this mode, JEXL should throw a JEXLException, but it is not in my case. I also understand from JEXL website that:

The JexlException are thrown in "non-silent" mode but since these are RuntimeException, user-code should catch them wherever most appropriate

I checked and no RuntimeException is thrown. JEXL only logs the error and (in my case) returns false (the method returns a boolean).

How can I force JEXL to throw an error (my error or JEXLException, it doesn't matter)?

有帮助吗?

解决方案

It seems I had to set strict mode too.

JexlEngine jexl = new JexlEngine();
jexl.setSilent(false);
jexl.setStrict(true);

I'm not sure if silent mode is actually necessary.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top