By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,957 Members | 2,038 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,957 IT Pros & Developers. It's quick & easy.

Unhandled exceptions checking

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.