468,306 Members | 1,432 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,306 developers. It's quick & easy.

Unhandled exceptions checking

Does somebody know existent tool for checking unhandled exceptions?
Like in Java when method throws exception but in code using this
method, try...catch is missed. May be something like PyChecker?

--
/Pavel
Jun 27 '08 #1
5 1248
On May 23, 6:31*pm, Yosifov Pavel <aqua...@gmail.comwrote:
Does somebody know existent tool for checking unhandled exceptions?
Like in Java when method throws exception but in code using this
method, try...catch is missed. May be something like PyChecker?

--
/Pavel
I know that pychecker doesn't do that. The set of handled exceptions
is probably much smaller than handled. Almost every line of code can
throw ten different exceptions (at least my code). I'm not sure what
specifically the output you'd like to see would look like.
Jun 27 '08 #2
On Sat, May 24, 2008 at 3:31 AM, Yosifov Pavel <aq*****@gmail.comwrote:
Does somebody know existent tool for checking unhandled exceptions?
Like in Java when method throws exception but in code using this
method, try...catch is missed. May be something like PyChecker?
Python is too dynamic to do this reliably. eg:

e = exception_returning_func()
raise e

You'll probably be better served by capturing and logging all
unhandled exceptions in your app ("logger.exception(e)" works nicely
in a high level "catch Exception e" block), and then notifying users.

Another thing to try is coverage testing. Won't raise all possible
exceptions in a given piece of code, but at least you can check if
all lines get run once.

David.
Jun 27 '08 #3
Yosifov Pavel wrote:
Does somebody know existent tool for checking unhandled exceptions?
Like in Java when method throws exception but in code using this
method, try...catch is missed. May be something like PyChecker?
I've seen this a number of places. Apparently there are a number
of programmers who find exceptions to be a problem to suppressed,
rather than an indicator of a deeper bug. Your goal should be to
handle anticipatable problems where you can, and reveal the others,
not to make sure you cannot raise an exception. Exceptions are
valuable in that they reveal "thinko"s, embrace what they tell you,
and don't look for mechanical ways to avoid them; test them out.

--Scott David Daniels
Sc***********@Acm.Org
Jun 27 '08 #4
On 24 ΝΑΚ, 12:58, bukzor <workithar...@gmail.comwrote:
On May 23, 6:31 pm, Yosifov Pavel <aqua...@gmail.comwrote:
Does somebody know existent tool for checking unhandled exceptions?
Like in Java when method throws exception but in code using this
method, try...catch is missed. May be something like PyChecker?
--
/Pavel

I know that pychecker doesn't do that. The set of handled exceptions
is probably much smaller than handled. Almost every line of code can
throw ten different exceptions (at least my code). I'm not sure what
specifically the output you'd like to see would look like.
OK. I understand point of view of all responders.
It seems I surmised why it's very difficult to do in tool like
PyChecker:
not only functions/methods but usual Python expression can mask
potential
exception source. And this tool must know how to parse every
expression
deep (to object protocol methods, for example). But it's possible in
principle...
And you are right: the output of this tool will be very verbal :-)

Thanks to all
Jun 27 '08 #5
On Sun, 25 May 2008 21:00:01 -0700, Yosifov Pavel wrote:
OK. I understand point of view of all responders.
It seems I surmised why it's very difficult to do in tool like
PyChecker: not only functions/methods but usual Python expression can
mask potential exception source. And this tool must know how to parse
every expression deep (to object protocol methods, for example). But
it's possible in principle...
So which *specific* exceptions can be thrown by this function:

def f():
raise globals()[raw_input()]()

Ciao,
Marc 'BlackJack' Rintsch
Jun 27 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by terry | last post: by
4 posts views Thread by Frank | last post: by
5 posts views Thread by Lucvdv | last post: by
reply views Thread by Colmeister | last post: by
2 posts views Thread by Bob | last post: by
3 posts views Thread by Andreas van de Sand | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by Teichintx | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.