• NotAThingThatHappens (unregistered)

    This is not as bad as it looks. When running in a debugger, the debugger can stop on the 'frist-chance-exception'. There you can read the informative exception message.

    /s

  • Prime Mover (unregistered)

    Not an honourable mention of the appalling indentation practices?

  • dpm (unregistered)

    This code is like a lonely child on the playground, throwing a ball up in the air and catching it themselves because no one else will play with them.

    Correction: the child first stabs the ball to let all the air out, leaving a limp piece of rubber which is useless for playing.

    i.e., ignoring the actual information in "e" and simply throwing a constant string, so that in the best case, someone will know that something went wrong, but not have any idea what happened or where.

  • Peter (unregistered) in reply to dpm

    “There is a theory which states that if ever anyone discovers exactly what the Exception is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable. There is another theory which states that this has already happened.”

  • The other Peter (unregistered)

    Don't forget the parameter in the JavaDoc that's not part of the signature.

  • giammin (unregistered)

    ON ERROR RESUME NEXT

  • (nodebb)

    . I guess we can say, "at least it's not regexes".

    It's equally as bad.

  • dpm (unregistered)

    Ah, the good old "$ ON ERROR THEN CONTINUE" from my days writing DCL command procedures on VMS . . . good times, good times.

  • (nodebb) in reply to giammin

    [Quote giammin]ON ERROR RESUME NEXT[/Quote] With higher memory requirements.

  • (nodebb)

    This is why XML is bad!

  • (nodebb) in reply to Bananafish

    This is why XML is bad!

    Not really. Nothing about XML mandates handling exceptions in a really WTF way. Also, the method of scanning through the data is a WTF with any recursively defined data format. It would be just as much a WTF if it were JSON or YAML.

  • Richard Brantley (unregistered) in reply to dpm

    That's what really drives me bonkers: the exception message that explains nothing.

  • (nodebb)

    Use a first chance exception handler as a logger.... then this pattern makes perfect sense....

    First Chance Exception loggers are often wired into other systems. For example, one NOC I was involved with would examine any first-chance exception and if it was not on a "white-list" (location and content) then it would generate a ticket. Depending on the module/stack trace this could start to set of a whole chain of people being woke up in the middle of the night.

    The developers were careful to ensure that "Exceptions were exceptional" and diligently pre-did all error checks for things with rates of occurances above a few ppm.... it was some of the best written code I have seen in 30 years of C++ development.

  • MaxiTB (unregistered)

    So this basically is what you get for checked exceptions, amirite lol

  • ooOOooGa (unregistered)

    I don't use .NET currently, so I may be wrong on this ...

    But wouldn't a first-chance exception handler be triggered when the outer try block throws an exception - before execution goes to that wonky catch block with its own thrown and caught exception?

  • MaxiTB (unregistered) in reply to ooOOooGa

    This is not .net code, it's Java ;-)

  • NotAThingThatHappens (unregistered) in reply to ooOOooGa
    Comment held for moderation.
  • Ralf (unregistered)
    Comment held for moderation.
  • Greg (unregistered) in reply to Peter

    Some knows his classics :-)

  • Gnasher729 (unregistered)

    When some code that I call throws exceptions, I will definitely want to know what exceptions and why (for example because I do something wrong calling the code). So at the very least I check which exceptions, ignore the ones that I know can be ignored, and make sure that I get notified if any exceptions arrive that I haven’t seen before.

Leave a comment on “Catch By Yourself”

Log In or post as a guest

Replying to comment #:

« Return to Article