Errors and Panics
Go error handling has been nothing but polarizing. Those who came from a background in languages with exception handling (such as Java) tend to hate it, and those who came from a background in languages where errors are values returned from functions (such as C) feel comfortable with it.
Having a background in both, I am of the opinion that the explicit nature of error handling forces you to think about exceptional situations at every step of the development. Error generation, error passing, and error handling require the same type of discipline and scrutiny as the “happy path” (which is when no errors happen).
If you noticed, I make a distinction between three phases of dealing with errors:
- Detection and generation of errors deal with detecting an exceptional situation and capturing diagnostic information
- Passing of errors deals with allowing errors to be propagated up the stack, optionally decorating them with contextual information...