Size: 1014
Comment:
|
Size: 1270
Comment: Updated example to use super()
|
Deletions are marked like this. | Additions are marked like this. |
Line 8: | Line 8: |
def __init__( self, host ): | def __init__(self, host): |
Line 10: | Line 10: |
Exception.__init__(self, 'Host Not Found exception: missing %s' % host) | super(HostNotFound, self)('Host Not Found exception: missing %s' % host) |
Line 18: | Line 18: |
raise HostNotFound( "taoriver.net" ) except HostNotFound, X: |
raise HostNotFound("taoriver.net") except HostNotFound, exc: |
Line 21: | Line 21: |
# "X" is the HostNotFound instance. | print exc # -> 'Host Not Found exception: missing taoriver.net' print exc.host # -> 'taoriver.net' |
Line 31: | Line 33: |
* When you're logging exceptions, you want access to the traceback information to. After some research, I believe what you use is extract_tb or extract_stack from the traceback module. -- 216.254.10.130 [[DateTime(2003-09-07T15:23:43Z)]] | * When you're logging exceptions, you want access to the traceback information to. After some research, I believe what you use is extract_tb or extract_stack from the traceback module. -- LionKimbro [[DateTime(2003-09-07T15:23:43Z)]] ''Look at cgitb for how to do detailed TB introspection, and as an example of why mixing logic and (HTML) layout is a very bad thing.'' |
Line 33: | Line 38: |
''AlexMartelli's "Dos and Don'ts".'' |
Writing Exception Classes
Exception classes are not special, you just derive them from Exception:
You may later write:
See Also
HandlingExceptions, TracebackModule
Questions
How do you relay the traceback information? Relay the traceback information? Moving it higher up the call-stack? Could you try to explain your question?
When you're logging exceptions, you want access to the traceback information to. After some research, I believe what you use is extract_tb or extract_stack from the traceback module. -- LionKimbro DateTime(2003-09-07T15:23:43Z)
Look at cgitb for how to do detailed TB introspection, and as an example of why mixing logic and (HTML) layout is a very bad thing.
- What better exception-foo is out there?
AlexMartelli's "Dos and Don'ts".