Output exception arguments, string representation of exception,and the traceback : Exception Info : Exception PYTHON examples


PYTHON examples » Exception » Exception Info »

 

Output exception arguments, string representation of exception,and the traceback


Output exception arguments, string representation of exception,and the traceback

import traceback

def function1():
   function2()

def function2():
   function3()

def function3():
   try:
      raise Exception, "An exception has occurred"
   except Exception:
      print "Caught exception in function3. Reraising....n"
      raise

try:
   function1()
except Exception, exception:
   print "Exception caught in main program."
   print "nException arguments:", exception.args
   print "nException message:", exception
   print "nTraceback:"
   traceback.print_exc()

           
       



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo Exception
» Exception Info


Warning: Unknown: write failed: No space left on device (28) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php/session) in Unknown on line 0