|
|
|
|
|
by morelisp
1035 days ago
|
|
> Any method or function which is not guaranteed to succeed by the language specification should, generally, return an error. Most Go programmers are too scared to panic and abort when invariants are violated. I think most codebases contain at least 2x as much error handling as is really necessary. |
|
Panic isn't an ersatz error reporting mechanism, it's a tool of absolute last resort. Any function or method that can fail should return an error, and should signal failure via that error. Callers that invoke any fallible function or method should always receive, inspect, and respond to the returned error.