28

I heard scary thing.
A tester found an issue yesterday. He came to the dev and reported about it. Apparently the only feedback message was "something went wrong". They spend almost an hour hunting down the cause for that. It turned out the error message was from one of the try-catch. I do not know much details apart from that. At the end, the dev lead said this (which he had said before).

"That's why I don't like to catch exception."

Comments
  • 0
    HOLD UP.
    Dilettante alert 😂🤦
    Not catching the possible exception is basically asking for trouble.
  • 6
    I don't like code. It can be abused by idiots.
  • 5
    Shouldn't we only catch exceptions we know how to handle?
  • 6
    Show him the below line, and you'll change his life forever.

    Ok ready?

    Here it goes:

    e.printStackTrance()
  • 2
    @orimligt Depends of the behaviour you want. Most cases you want to have an all-exception catcher to log the error and stacktrace, print error message to user, save the state of the App, revert changes of the user, etc
  • 2
    @pmso I get your point and I agree to a high degree, but I also think that it depends on which type of application it is and who the end users are. Logging should always be done, and some exceptions doesn't have to be shown to the user and could be catched with a catch all. When using an application catch-all we can gracefully exit. The reasoning behind only catching the errors we could expect is that we know how to handle them. On that track, in my taste exceptions should never origin from our own code, but rather from sources we can't control.
  • 10
    Well. He has a point.

    If you are going to catch an exception you really need to do something useful with it.

    Hiding errors behind generic error messages is evil.
  • 2
  • 1
    @ReverendLovejoy Without proper logging, yes. But in most cases attempting a graceful exit from an unknown state is still preferred to just crashing the app.
  • 0
    @Lor-inc I agree. Sadly that seldom happens. In many situations people are so focused on the happy-path that they don't even know how to exit their own code when the unexpected happens.
Add Comment