sys.exc_info() into string
cliechti at gmx.net
Sun Jun 23 21:17:39 CEST 2002
Magnus <spammers.do.not.bother at void.bogus> wrote in
news:KZoR8.44805$n4.10504231 at newsc.telia.net:
> in my program I am catching exceptions that I might have missed by
> using something like:
> type = sys.exc_info()
> syslog.syslog(syslog.LOG_EMERG, "My program: unexpected error"
> + type)
> The thing is that I can not figure out how to make "type" into a
> string above so I can use it for e.g. syslog(). Is there an easy way
> of doing this?
yes, the traceback module has functions to format an exception as string or
format_exc is a candidate for you. it return a list of lines from which you
can select to mosr informative or just join it the one big string.
Chris <cliechti at gmx.net>
More information about the Python-list