logoalt Hacker News

stouset06/04/20251 replyview on HN

> 90% of the time, err != nil is enough

Only if your only desire is to bubble the error up and quite literally not handle it at all.

If you want to actually handle an error, knowing what actually went wrong is critical.


Replies

kiitos06/04/2025

Returning an error -- or, more accurately, identifying an error and returning an annotation or transformation of that error appropriate for your caller -- is a way of handling it. The cases where, when your code encounters an error, that it can do anything other than this are uncommon.

show 2 replies