Connecting Tech Pros Worldwide Forums | Help | Site Map

cathing uncaught exceptions

Alexandru Mosoi
Guest
 
Posts: n/a
#1: Aug 18 '08
how can I catch (globally) exception that were not caught in a try/
catch block in any running thread? i had this weird case that an
exception was raised in one thread, but nothing was displayed/logged.

Paul McGuire
Guest
 
Posts: n/a
#2: Aug 18 '08

re: cathing uncaught exceptions


On Aug 18, 10:02*am, Alexandru Mosoi <brtz...@gmail.comwrote:
Quote:
how can I catch (globally) exception that were not caught in a try/
catch block in any running thread? i had this weird case that an
exception was raised in one thread, but nothing was displayed/logged.
I suspect that your weird case was *not* because your exception was
uncaught, but because it *was* caught and just discarded. Look
through your code for something like this:

except ExceptionIDontExpectToEverGet:
pass

or even worse:

except:
pass

I'll bet one of these was your "exception non-logger" culprits.

-- Paul
Alexandru Mosoi
Guest
 
Posts: n/a
#3: Aug 18 '08

re: cathing uncaught exceptions


On Aug 18, 6:18*pm, Paul McGuire <pt...@austin.rr.comwrote:
Quote:
On Aug 18, 10:02*am, Alexandru *Mosoi <brtz...@gmail.comwrote:
>
Quote:
how can I catch (globally) exception that were not caught in a try/
catch block in any running thread? i had this weird case that an
exception was raised in one thread, but nothing was displayed/logged.
>
I suspect that your weird case was *not* because your exception was
uncaught, but because it *was* caught and just discarded. *Look
through your code for something like this:
>
* * except ExceptionIDontExpectToEverGet:
* * * * pass
>
or even worse:
>
* * except:
* * * * pass
>
I'll bet one of these was your "exception non-logger" culprits.
>
-- Paul

sorry, no... i used except: print 'something' to validate that there
is an exception that was raised :). otherwise, i avoid your second
construct in my code (just because I don't want to miss strange cases
like this one).
Alexandru Mosoi
Guest
 
Posts: n/a
#4: Aug 19 '08

re: cathing uncaught exceptions


On Aug 18, 6:02*pm, Alexandru Mosoi <brtz...@gmail.comwrote:
Quote:
how can I catch (globally) exception that were not caught in a try/
catch block in any running thread? i had this weird case that an
exception was raised in one thread, but nothing was displayed/logged.
I found that normally sys.excepthook is invoked for uncaught
exceptions. however in my case the function is not invoked (as it
should normaly do). i printed the stackframe and checked that there is
no try/catch block that handles the exception. any other idea?
Rafe
Guest
 
Posts: n/a
#5: Aug 19 '08

re: cathing uncaught exceptions


On Aug 18, 10:02 pm, Alexandru Mosoi <brtz...@gmail.comwrote:
Quote:
how can I catch (globally) exception that were not caught in a try/
catch block in any running thread? i had this weird case that an
exception was raised in one thread, but nothing was displayed/logged.
Any chance you might have missed the word "raise", e.g.

except Exception, err:
Exception(err)

vs.

except Exception, err:
raise Exception(err)


This is from the list of stupid things I have done myself,

- Rafe
Gabriel Genellina
Guest
 
Posts: n/a
#6: Aug 19 '08

re: cathing uncaught exceptions


En Mon, 18 Aug 2008 12:02:29 -0300, Alexandru Mosoi <brtzsnr@gmail.comescribió:
Quote:
how can I catch (globally) exception that were not caught in a try/
catch block in any running thread? i had this weird case that an
exception was raised in one thread, but nothing was displayed/logged.
Each thread should handle its own exceptions. If any exception escapes from Threading.run(), it is printed on sys.stderr (sys.excepthook isn't involved); see the threading.py module for details.
Maybe you had a bare try/except that did nothing? or maybe you redirected sys.stderr?

--
Gabriel Genellina

Closed Thread