Unhandled exceptions checking

Y

Yosifov Pavel

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?
 
B

bukzor

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 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.
 
D

David

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.
 
Y

Yosifov 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
 
M

Marc 'BlackJack' Rintsch

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top