Import not Work

Why don’t Exception handlers catch exceptions???

try


system.db.runPrepUpdate(… This fails and the whole script stops running

except Exception, e:
Never reach this line of code!!! Why not???

Thanks,
Russ

.

Jython’s Exception class does not inherit from Java’s base exception class - so exceptions thrown in Java code (ie, everything written by Inductive Automation) are not caught by Exception clauses. You have to catch both possible exceptions:

import java.lang.Exception

try:
    # something something something
except Exception, e:
    # jython exception
except java.lang.Exception, e:

or

import java.lang.Exception

try:
    # something something something
except (Exception, java.lang.Exception), e:
	#pass
1 Like

Thank you sir! I was explaining to others here how Exception (as the base class of all Exceptions) should catch everything…wrong base class!!

1 Like