Catch IOException?

Consider using two except blocks, as jython's standard Exception won't catch pure java exceptions. Like so:

import java.lang.Exception

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

Update:

For better coverage and less chance of name conflict, I've been recommending this construct lately:

from java.lang import Throwable

try:
    # something something something
except Throwable, t:
    # Java exception handling
except Exception, e:
    # Jython exception handling
7 Likes