Last active
October 4, 2020 22:35
-
-
Save martinsson/8df118bbecdd2afe482886aaf8c854a7 to your computer and use it in GitHub Desktop.
Error handling trick in GoLang 1/3 : CombineErrors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func createConnection(store Store) (Connection, error) { | |
tenantID, err := store.GetParameter("TENANT_ID") | |
if err != nil { | |
fmt.Print("Unable to get TENANT_ID from parameter store") | |
return nil, err | |
} | |
clientID, err := store.GetParameter("CLIENT_ID") | |
if err != nil { | |
fmt.Print("Unable to get CLIENT_ID from parameter store") | |
return nil, err | |
} | |
clientSecret, err := store.GetParameter("CLIENT_SECRET") | |
if err != nil { | |
fmt.Print("Unable to get CLIENT_SECRET from parameter store") | |
return nil, err | |
} | |
return connection{ | |
tenantID, | |
clientID, | |
clientSecret, | |
}, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment