Tuesday, 2 January 2024

python generic exception handling and logging

 https://wiki.python.org/moin/HandlingExceptions

https://stackoverflow.com/questions/8238360/how-to-save-traceback-sys-exc-info-values-in-a-variable

 1 import sys
   2 try:
   3   untrusted.execute()
   4 except: # catch *all* exceptions
   5   e = sys.exc_info()[0]
   6   write_to_page( "<p>Error: %s</p>" % e )


// cast e to str

str(e)


No comments:

Post a Comment