General statistics
List of Youtube channels
Youtube commenter search
Distinguished comments
About
Christian Baune
ThePrimeTime
comments
Comments by "Christian Baune" (@programaths) on "err != nil Is GOOD? (And Why)" video.
You can also mitigate the issue. I do Apex, and I have objects with embedded error handling. That sounds weird since it breaks the single responsibility principle, but it simplifies the code for the caller. You can chain methods using the same objects; each method knows to bail out if you provide an error. This means you can write your implementation and check for errors in one place, handle the error anywhere, and provide an error-free object to continue the chain. The API is mostly for noncoders who can't handle errors (they don't even think about it), so it has to be as robust as possible. And by avoiding throwing exceptions, it's made very explicit. The language doesn't support Generics; otherwise, I would have done a wrapper with overloaded methods accepting those wrappers.
1