Return errors for:
- Expected failures (file not found, invalid input)
- Recoverable situations
- Anything the caller might handle
Use panic for:
- Programming bugs
- Impossible states
- Failed invariants
When in doubt, return an error. Panics should be rare.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
Choosing the right approach
Return errors for:
Use panic for:
When in doubt, return an error. Panics should be rare.