A panic should not mean it takes the whole service down. In fact, you absolutely must have a recover at the top level of the request. Most frameworks including the http package will give you this for free.

The panic on an unexpected error (that is, an error that has not reasonble recovery path) acts as a short circuit to kill the request because it’s impossible to proceed anyway. The point I’m making in this artcile is that an unexpected error would have to be passed all the way up the chain anyway.

Creating lots of extra if-err-return to pass up unrecoverable errors does not make your code more reliable, it just creates extra branches that will likely never have unit tests.

Written by

I’m a data nerd and TDD enthusiast originally from Sydney. Currently working for Uber in New York. My thoughts here are my own. 🤓 elliotchance@gmail.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store