Ramy Ramy - 1 year ago 105
Python Question

where's the rest of ironpython exception?

I could be wrong, but it seems I'm only getting incomplete stack traces and exception messages when a SystemError is raised in IronPython. I'm doing this:

with SQLConnection(DATASOURCES[SCHEDULEDB]) as db:
db.execute_sql( command + ' ' + ','.join(block) + ';' )
except Exception, e:
print 'caught an exception'
print "Unexpected error:", sys.exc_info()[0]
print e

however, all i'm seeing is this:

Traceback (most recent call last):
SystemError: The connection has been disabled.

Answer Source


import traceback

Instead of printing the exception object directly. In Python exception objects don't hold onto the stack trace directly - instead they're part of the trio of items in sys.exc_info().

You could also do:

import System

except System.Exception, e:

and you'll get a normal .NET exception object instead of the Python exception object.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download