[code.view]

[top] / python / PyMOTW / cgitb / cgitb_exception_properties.py

     #!/usr/bin/env python
     # encoding: utf-8
     #
     # Copyright (c) 2009 Doug Hellmann.  All rights reserved.
     #
     """Showing exception properties in a traceback
     """
     #end_pymotw_header
     
     import cgitb
     cgitb.enable(format='text')
     
     class MyException(Exception):
         """Add extra properties to a special exception
         """
         
         def __init__(self, message, bad_value):
             self.bad_value = bad_value
             Exception.__init__(self, message)
             return
     
     raise MyException('Normal message', bad_value=99)
     

[top] / python / PyMOTW / cgitb / cgitb_exception_properties.py

contact | logmethods.com