[JSR223] Catching Script Exception with jython

Hi,

I am trying to catch an error.
Unfortunately the exception does not get handled.
How can I catch this exception?

        try:
            return ir.getItemByPattern( "Test.+")
        except Exception as e:
            logger.error("{}".format(e)
            return None
2017-05-14 11:19:28.248 [ERROR] [o.o.c.j.i.e.s.ScriptManager   ] - script exception
javax.script.ScriptException: org.openhab.core.items.ItemNotUniqueException: org.openhab.core.items.ItemNotUniqueException: Item cannot be uniquely identified by 'Test.+' in <script> at line number 34
        at org.python.jsr223.PyScriptEngine.scriptException(PyScriptEngine.java:202) ~[jython.jar:na]
        at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:42) ~[jython.jar:na]
        at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:47) ~[jython.jar:na]
        at javax.script.AbstractScriptEngine.eval(Unknown Source) ~[na:1.8.0_131]
        at org.openhab.core.jsr223.internal.engine.scriptmanager.Script.loadScript(Script.java:91) ~[bundlefile:na]
        at org.openhab.core.jsr223.internal.engine.scriptmanager.Script.<init>(Script.java:79) ~[bundlefile:na]
        at org.openhab.core.jsr223.internal.engine.scriptmanager.ScriptManager.loadScript(ScriptManager.java:90) [bundlefile:na]
        at org.openhab.core.jsr223.internal.engine.scriptmanager.ScriptManager.scriptsChanged(ScriptManager.java:185) [bundlefile:na]
        at org.openhab.core.jsr223.internal.engine.scriptmanager.ScriptUpdateWatcher.run(ScriptUpdateWatcher.java:105) [bundlefile:na]
        at java.lang.Thread.run(Unknown Source) [na:1.8.0_131]
Caused by: org.python.core.PyException: null
        at org.python.core.Py.JavaError(Py.java:546) ~[jython.jar:na]
        at org.python.core.Py.JavaError(Py.java:537) ~[jython.jar:na]
        at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:188) ~[jython.jar:na]
        at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:204) ~[jython.jar:na]
        at org.python.core.PyObject.__call__(PyObject.java:478) ~[jython.jar:na]
        at org.python.core.PyObject.__call__(PyObject.java:482) ~[jython.jar:na]
        at org.python.core.PyMethod.__call__(PyMethod.java:141) ~[jython.jar:na]
        at EasyRule.OHTypes.OHItemRegistry$py.getItemByPattern$3(<script>:29) ~[na:na]
        at EasyRule.OHTypes.OHItemRegistry$py.call_function(<script>) ~[na:na]
        at org.python.core.PyTableCode.call(PyTableCode.java:167) ~[jython.jar:na]
        at org.python.core.PyBaseCode.call(PyBaseCode.java:153) ~[jython.jar:na]
        at org.python.core.PyFunction.__call__(PyFunction.java:423) ~[jython.jar:na]
        at org.python.core.PyMethod.__call__(PyMethod.java:141) ~[jython.jar:na]
        at org.python.pycode._pyx53.f$0(<script>:46) ~[na:na]
        at org.python.pycode._pyx53.call_function(<script>) ~[na:na]
        at org.python.core.PyTableCode.call(PyTableCode.java:167) ~[jython.jar:na]
        at org.python.core.PyCode.call(PyCode.java:18) ~[jython.jar:na]
        at org.python.core.Py.runCode(Py.java:1386) ~[jython.jar:na]
        at org.python.core.__builtin__.eval(__builtin__.java:497) ~[jython.jar:na]
        at org.python.core.__builtin__.eval(__builtin__.java:501) ~[jython.jar:na]
        at org.python.util.PythonInterpreter.eval(PythonInterpreter.java:259) ~[jython.jar:na]
        at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:40) ~[jython.jar:na]
        ... 8 common frames omitted
Caused by: org.openhab.core.items.ItemNotUniqueException: Item cannot be uniquely identified by 'Test.+'
        at org.openhab.core.internal.items.ItemRegistryImpl.getItemByPattern(ItemRegistryImpl.java:95) ~[na:na]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_131]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_131]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_131]
        at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:186) ~[jython.jar:na]
        ... 27 common frames omitted

The existing code will only catch Python exceptions. Either catch the specific Java exception, a base Java exception (like java.lang.Exception or java.lang.Throwable) or use the except keyword without an exception specifier and use sys.exc_info() to get the exception details.

Thanks - this fixed it.
For the next one that searches this problem:

import org.openhab.core.items.ItemNotUniqueException
try:
    ir.getItemByPattern("Test.+")
except org.openhab.core.items.ItemNotUniqueException as e:
    logger.error("{}".format(e))
    return None