Uploaded image for project: 'Commons JEXL'
  1. Commons JEXL
  2. JEXL-17

ExpressionFactory.createNewExpression should throw an Exception in case of a parsing error, not Error

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.0
    • Fix Version/s: 1.1
    • Labels:
      None

      Description

      When ExpressionFactory.createNewExpression(...) takes an syntactically incorrect expression, JEXL throws TokenMgrError. However, typical callers (such as Jelly) don't expect such syntax error to be a java.lang.Error, so it fails to catch it.

      A typical outcome is therefore the thread to die completely, and even worse the stack trace doesn't report neither what was the expression that was being parsed, nor does it report any contextual information (again in case of Jelly, that would be where in the jelly script this error happened.)

      This makes the error diagnosis unnecessarily hard. I believe the proper thing to do is to wrap such an exception into java.lang.Exception or its sub-class, allowing the caller to catch it.

        Attachments

        1. JEXL-17.diff
          3 kB
          Kohsuke Kawaguchi

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              kohsuke Kohsuke Kawaguchi
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: