Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #43486
| From | "Prasad, Ramit" <ramit.prasad@jpmorgan.com> |
|---|---|
| Subject | RE: newbie question about confusing exception handling in urllib |
| Date | 2013-04-12 21:29 +0000 |
| References | <1ae3261b-078d-4362-abff-ea4471addd6a@googlegroups.com> <c395da30-c593-4aeb-960e-69bf98c31880@googlegroups.com> <51642e32$0$30003$c3e8da3$5496439d@news.astraweb.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.537.1365802247.3114.python-list@python.org> (permalink) |
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.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
newbie question about confusing exception handling in urllib cabbar@gmail.com - 2013-04-09 04:41 -0700
Re: newbie question about confusing exception handling in urllib Peter Otten <__peter__@web.de> - 2013-04-09 14:19 +0200
Re: newbie question about confusing exception handling in urllib cabbar@gmail.com - 2013-04-09 06:19 -0700
Re: newbie question about confusing exception handling in urllib Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-09 15:05 +0000
Re: newbie question about confusing exception handling in urllib Chris Angelico <rosuav@gmail.com> - 2013-04-10 02:23 +1000
RE: newbie question about confusing exception handling in urllib "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2013-04-12 21:29 +0000
Re: newbie question about confusing exception handling in urllib Terry Jan Reedy <tjreedy@udel.edu> - 2013-04-09 10:19 -0400
Re: newbie question about confusing exception handling in urllib Ian Kelly <ian.g.kelly@gmail.com> - 2013-04-09 13:11 -0600
csiph-web