Skip to content

Instantly share code, notes, and snippets.

@martinsson
Last active October 4, 2020 22:36
Show Gist options
  • Save martinsson/fc43ff769a2b7856aac6b103f635fab0 to your computer and use it in GitHub Desktop.
Save martinsson/fc43ff769a2b7856aac6b103f635fab0 to your computer and use it in GitHub Desktop.
Error handling in GO 2/3 : A better version of the error handling. No more if statement per variable
tenantID, err1 := store.GetParameter("TENANT_ID")
clientID, err2 := store.GetParameter("CLIENT_ID")
clientSecret, err3 := store.GetParameter("CLIENT_SECRET")
globalErr := multierr.Combine(err1, err2, err3)
if globalErr != nil {
fmt.Print(globalErr)
return nil, globalErr
}
return connection{
tenantID,
clientID,
clientSecret,
}, nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment