Search in sources :

Example 1 with BPjsRuntimeException

use of il.ac.bgu.cs.bp.bpjs.exceptions.BPjsRuntimeException in project BPjs by bThink-BGU.

the class JsEventSet method contains.

@Override
public boolean contains(BEvent event) {
    try {
        Object result = predicate.call(Context.getCurrentContext(), predicate, predicate.getParentScope(), new Object[] { Context.javaToJS(event, predicate.getParentScope()) });
        Boolean res = (Boolean) Context.jsToJava(result, Boolean.class);
        if (res == null) {
            throw new RuntimeException("JS Predicate returned null, not a boolean value. " + predicate.toString());
        }
        return res;
    } catch (EvaluatorException ee) {
        throw new BPjsRuntimeException("JS Predicate did not return a boolean value.", ee);
    } catch (EcmaError ee) {
        throw new BPjsRuntimeException("Error evaluating JS Predicate:" + ee.getMessage(), ee);
    }
}
Also used : BPjsRuntimeException(il.ac.bgu.cs.bp.bpjs.exceptions.BPjsRuntimeException) EcmaError(org.mozilla.javascript.EcmaError) EvaluatorException(org.mozilla.javascript.EvaluatorException) BPjsRuntimeException(il.ac.bgu.cs.bp.bpjs.exceptions.BPjsRuntimeException)

Aggregations

BPjsRuntimeException (il.ac.bgu.cs.bp.bpjs.exceptions.BPjsRuntimeException)1 EcmaError (org.mozilla.javascript.EcmaError)1 EvaluatorException (org.mozilla.javascript.EvaluatorException)1