Hi, I'm looking for thoughts from some experienced go programmers on a
technique to reduce error handling verbosity.
The basic idea is to be optimistic over a few instructions, and then
combine many errors in to one. This gist and explains the idea (note the
absence of if err != nil {} )
tenantID, err1 := store.GetParameter("TENANT_ID")
clientID, err2 := store.GetParameter("CLIENT_ID")
clientSecret, err3 := store.GetParameter("CLIENT_SECRET")
globalErr := multierr.Combine(err1, err2, err3)
return connection{
tenantID,
clientID,
clientSecret,
}, globalErr
There's some more detail in a post
http://martinsson-johan.blogspot.com/2020/10/less-error-handling-noice-in-go.html.
I'm sure someone else has already proposed this, but I wasn't able to find
it. Grateful for pointers
While it seems sound to me I'm a very interested in what people from the
community thinks.
Cheers
Johan Martinsson
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/03d0ff66-3767-40a0-8552-4e124f1cc44bn%40googlegroups.com.