7

Maybe I am just a fucking idiot, but I don’t get error handling at all. I’m always torn between what level the error should go, where it should go, and what to even do about it. Why has this burden of choice plagued me?!?

It’s like this question I can never figure out. How to react to certain things appropriately, because who can say that and be 100% correct about their opinion.

Comments
  • 3
    i would say it's not very clear cut, but you could ask the other side of the question:

    How you shouldn't do error handling:

    - fail silently
    - throw the errors up the chain to halt the program
    - dont describe the error (useless message)
    - not catch it at all
    - catch everything no questions ask etc.
    - check for errors in often run code (except performance is not a concern)
    - there are probably much more things

    if you ask yourself these types of questions, it will eliminate a lot of places and you will end up with a few possible solutions.
  • 2
    and for what to do:

    well, either rollback/reset state
    or bring the state into stable again
    or discard state and crash with error,
    depending on the severity and use case

    in some cases it might be enough, to warn about something and keep going
  • 1
    there are lots of tutorials on the subject. I remember there was a great post on the Joyent site about it that really helped me a few years ago, but it seems to be 404 now.

    I'd say the most important thing is that when an error becomes enduser-facing, it should be as clear and user-friendly as possible, and the interface should give the user an easy way to recover, work around (if possible), and move on.
Add Comment