Steven D'Aprano wrote:
> try:
>     main()
> except Exception as err:
>     log(err)
>     print("Sorry, an unexpected error has occurred.")
>     print("Please contact support for assistance.")
>     sys.exit(-1)
> 
> 

I like the traceback[0] module for logging last exception thrown.
See traceback.format_exc() or traceback.print_exc().

trace = traceback.format_exc()
log.error('I was trying to do <action>, but unexpected 
error.\n{0}'.format(trace))

[0] http://docs.python.org/2/library/traceback.html


~Ramit



This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to