E
erick_bodine
In Martinelli's Nutshell book in the Exceptions chapter there is an
example of a custom exception class (pg.112) that I am trying to
implement without success. The custom exception class example pulls
sys.exc_info() into an attribute and I am assuming that the attribute
would then contain the raised exception info in a tuple (admittedly I
could be assuming erroneously).
class LinuxDriverError(Exception):
def __init__(self, *args):
Exception.__init__(self, *args)
self.message = args[0]
self.wrapped_exc = sys.exc_info()
try:
raise LinuxDriverError, "raising Cain!"
except CustomException, error:
print error.message
print error.wrapped_exc
# just checking
print "sys.exc_info(): ", sys.exc_info()
If I run the above code I get the following output:
Just raising Cain!
wrapped_exc: (None, None, None)
sys.exc_info(): (<class __main__.LinuxDriverError at 0xf6f774dc>,
<__main__.LinuxDriverError instance at 0xf6f74bec>, <traceback object
at 0xf6f7193c>)
I do not understand why the wrapped_exc attribute contains no objects.
I am running 2.3.4 on a fedora core 3 box.
thanks,
erick
example of a custom exception class (pg.112) that I am trying to
implement without success. The custom exception class example pulls
sys.exc_info() into an attribute and I am assuming that the attribute
would then contain the raised exception info in a tuple (admittedly I
could be assuming erroneously).
class LinuxDriverError(Exception):
def __init__(self, *args):
Exception.__init__(self, *args)
self.message = args[0]
self.wrapped_exc = sys.exc_info()
try:
raise LinuxDriverError, "raising Cain!"
except CustomException, error:
print error.message
print error.wrapped_exc
# just checking
print "sys.exc_info(): ", sys.exc_info()
If I run the above code I get the following output:
Just raising Cain!
wrapped_exc: (None, None, None)
sys.exc_info(): (<class __main__.LinuxDriverError at 0xf6f774dc>,
<__main__.LinuxDriverError instance at 0xf6f74bec>, <traceback object
at 0xf6f7193c>)
I do not understand why the wrapped_exc attribute contains no objects.
I am running 2.3.4 on a fedora core 3 box.
thanks,
erick