Unhandled exceptions checking

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Yosifov Pavel

    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
  • bukzor

    #2
    Re: Unhandled exceptions checking

    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.

    Comment

    • David

      #3
      Re: Unhandled exceptions checking

      On Sat, May 24, 2008 at 3:31 AM, Yosifov Pavel <aquagnu@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_retur ning_func()
      raise e

      You'll probably be better served by capturing and logging all
      unhandled exceptions in your app ("logger.except ion(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.

      Comment

      • Scott David Daniels

        #4
        Re: Unhandled exceptions checking

        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
        Scott.Daniels@A cm.Org

        Comment

        • Yosifov Pavel

          #5
          Re: Unhandled exceptions checking

          On 24 ÍÁÊ, 12:58, bukzor <workithar...@g mail.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

          Comment

          • Marc 'BlackJack' Rintsch

            #6
            Re: Unhandled exceptions checking

            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

            Comment

            Working...