title: Catch exception thrown by custom function in JEXL
body: <p>I added some functions to the JEXL engine wich can be used in the JEXL expressions:</p>
  
  <pre><code>Map&lt;String, Object&gt; functions = new HashMap&lt;String, Object&gt;();
  
  mFunctions = new ConstraintFunctions();
  functions.put(null, mFunctions);
  mEngine.setFunctions(functions);
  </code></pre>
  
  <p>However, some functions can throw exceptions, for example:</p>
  
  <pre><code>public String chosen(String questionId) throws NoAnswerException {
          Question&lt;?&gt; question = mQuestionMap.get(questionId);
          SingleSelectAnswer&lt;?&gt; answer = (SingleSelectAnswer&lt;?&gt;) question.getAnswer();
          if (answer == null) {
              throw new NoAnswerException(question);
          }
          return answer.getValue().getId();
  }
  </code></pre>
  
  <p>The custom function is called when i interpret an expression. The expression of course holds a call to this function:</p>
  
  <pre><code>String expression = "chosen('qID')";
  Expression jexl = mEngine.createExpression(expression);
  String questionId = (String) mExpression.evaluate(mJexlContext);
  </code></pre>
  
  <p>Unfortunetaly, when this function is called in course of interpretation, if it throws the <code>NoAnswerException</code>, the interpreter does not propagete it to me, but throws a general <code>JEXLException</code>. Is there any way to catch exceptions from custom functions? I use the <a href="http://commons.apache.org/proper/commons-jexl/index.html" rel="nofollow">apache commons JEXL</a> engine for this, which is used as a library jar in my project.</p>