News for hackers. Stuff that matters.
Re:Upcoming Features in Go 1.18 by sethammons on Tuesday November 09, 2021 @02:45PM (#29166495)
Doing some analysis, "naked" if-err-return-err shows up in about 5% of error handling cases in my team's most critical service.

The rest of the error blocks do something more (attempt a fallback, add context, log something, metric something, etc). This is code base that has been worked on for about 6 years, around 40k lines of code, 32 contributors, and over 450 releases. This is a legit production mail transfer agent. Take this as an experience report on a real system: that pattern is not as common as you think. 5% is pretty low.

Re:Upcoming Features in Go 1.18 by irq-1 on Tuesday November 09, 2021 @03:34PM (#29167093)
Curious if there is a one liner that would cover 80%+ of the error handling: onerror add context and return ; onerror function(err) and return ;
Re:Upcoming Features in Go 1.18 by sethammons on Tuesday November 09, 2021 @03:56PM (#29167370)
Error handling differs. But we try to move up metrics and logs as high as possible in the call chain. Handling an error may be a retry with a strategy, moving items to different queues, changing concurrency, potentially triggering jobs to run, feeding different events to event streams, and, of course, retuning errors to callers so they can programmatically respond.