Unhandled exceptions checking

Discussion in 'Python' started by Yosifov Pavel, May 24, 2008.

  1. 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
    Yosifov Pavel, May 24, 2008
    #1
    1. Advertising

  2. Yosifov Pavel

    bukzor Guest

    On May 23, 6:31 pm, 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?
    >
    > --
    > /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.
    bukzor, May 24, 2008
    #2
    1. Advertising

  3. Yosifov Pavel

    David Guest

    On Sat, May 24, 2008 at 3:31 AM, 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?
    >


    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.
    David, May 24, 2008
    #3
  4. On 24 ÍÁÊ, 12:58, bukzor <> wrote:
    > On May 23, 6:31 pm, 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?

    >
    > > --
    > > /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
    Yosifov Pavel, May 26, 2008
    #4
  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
    Marc 'BlackJack' Rintsch, May 26, 2008
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. terry

    Unhandled Exceptions & Framesets

    terry, Jul 2, 2003, in forum: ASP .Net
    Replies:
    5
    Views:
    425
    Bassel Tabbara [MSFT]
    Jul 3, 2003
  2. Replies:
    1
    Views:
    397
    Darren Kopp
    Mar 7, 2006
  3. Alan Silver

    How do I catch unhandled exceptions

    Alan Silver, Mar 20, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    1,726
    Alan Silver
    Mar 23, 2006
  4. Winista

    Unhandled Exceptions thrown

    Winista, Mar 22, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    399
    Winista
    Mar 22, 2006
  5. Warren Tang
    Replies:
    1
    Views:
    875
    Warren Tang
    Sep 23, 2008
Loading...

Share This Page