June 2002
Beginner to intermediate
640 pages
14h 24m
English
Exception class instances have the attributes filename, lineno, offset, and text. You can access these details to locate where your code failed. The next example (chap7_3.py) shows how:
class MyException(Exception):
pass
def raiseMyException():
raise Exception()
def catchMyException():
try:
raiseMyException()
except MyException, err:
print "line number " +err.lineno
print "file name " + err.filename
print "offset " + err.offset
print " text " + err.text
Read now
Unlock full access