[Zope] Exceptions in Python Scripts

Geir Bækholt Geir Bækholt
Wed, 14 May 2003 10:13:41 +0200


On  Wed, 14 May 2003 16:18:29 +1000 GMT (..8:18 where i live(GMT+2) )
drew nichols asked the Zope mailinglist about the following:
  
dn> I want to get a handle to the exception raised in a Python Script

dn> try:
dn>     x=1/0
dn> except:
dn>     print exception.id()
dn>     print exception.traceback()


dn> is there a built in var for the exception object.
dn> I need the type of exception and perhaps the line number

dn> I understand i can't import sys so how is this done??

i know i have done the following a lot of times:

try:
    x=1/0
except Exception, e:
    # now, the exception object is assigned to  'e'
    print str(e)
    return printed


:)


--
Geir Bækholt