Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Commit

Permalink
Namespaced error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
florisvdg committed Feb 26, 2019
1 parent e50dd28 commit 2762e04
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@ func init() {

if credential == "" {
flag.Usage()
os.Exit(1)
exit(fmt.Errorf("credential is required"))
}

cred, err := secrethub.NewCredential(credential, credentialPassphrase)
if err != nil {
fmt.Println(err)
os.Exit(1)
exit(err)
}

client = secrethub.NewClient(cred, nil)
Expand All @@ -44,8 +43,7 @@ func init() {
func main() {
err := startHTTPServer()
if err != nil {
fmt.Println(err)
os.Exit(1)
exit(err)
}
}

Expand Down Expand Up @@ -134,3 +132,8 @@ func handleSecret(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusMethodNotAllowed)
}
}

func exit(err error) {
fmt.Printf("secrethub-clientd: error: %v\n", err)
os.Exit(1)
}

0 comments on commit 2762e04

Please sign in to comment.