Elliot Chance
1 min readMay 24, 2020

--

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.

--

--

Elliot Chance
Elliot Chance

Written by Elliot Chance

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

Responses (1)