Hi,
My code looks like this:
for item in bigset:
self.__sub1(item)
self.__sub2(item)
self.__sub3(item)
# the subX functions, in turn, use various 3rd party modules.
Now, I would like to do this:
for item in bigset:
try:
self.__sub1(item)
self.__sub2(item)
"Allen Fowler" <[EMAIL PROTECTED]> wrote
> Now, I would like to do this:
>
> for item in bigset:
> try:
> self.__sub1(item)
> self.__sub2(item)
> self.__sub3(item)
> except StandardError:
> # Log error and continue to next item in set.
> log_error_to_file()
>
>
On 10/10/07, Alan Gauld <[EMAIL PROTECTED]> wrote:
>
> "Allen Fowler" <[EMAIL PROTECTED]> wrote
>
> > Now, I would like to do this:
> >
> > for item in bigset:
> > try:
> > self.__sub1(item)
> > self.__sub2(item)
> > self.__sub3(item)
> > except StandardError:
> > # Log error an
"Kalle Svensson" <[EMAIL PROTECTED]> wrote
>> but only if the data is in scope. If it is local data within the
>> raising function then bit will be gone by the time you catch
>> the exception.
>
> Well, not entirely. If you look at the sys.exc_info() function there
> is a way to get the backtrace
Allen Fowler wrote:
> In the error log, I would like to record a stacktrace and various local
> variables that existed in subX at the time the Exception was thrown...
The stack trace is easy - add the parameter exc_info=True to the logging
call, e.g.
logging.error('Oops!', exc_info=True)
Wh