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

Commit

Permalink
Translate status errors into easier to digest human messages
Browse files Browse the repository at this point in the history
  • Loading branch information
evanphx committed Jun 11, 2020
1 parent 1663ce4 commit 5951f95
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cmd/waypoint-entrypoint/main.go
Expand Up @@ -9,6 +9,7 @@ import (
"unicode"

"github.com/hashicorp/go-hclog"
"google.golang.org/grpc/status"

"github.com/hashicorp/waypoint/internal/ceb"
"github.com/hashicorp/waypoint/internal/pkg/signalcontext"
Expand Down Expand Up @@ -42,13 +43,21 @@ func realMain() int {
ceb.WithExec(args))
if err != nil {
fmt.Fprintf(flag.CommandLine.Output(),
"Error initializing Waypoint entrypoint: %s\n", err)
"Error initializing Waypoint entrypoint: %s\n", formatError(err))
return 1
}

return 0
}

func formatError(err error) string {
if s, ok := status.FromError(err); ok {
return s.Message()
}

return err.Error()
}

func usage() {
fmt.Fprintf(flag.CommandLine.Output(),
strings.TrimLeftFunc(usageText, unicode.IsSpace),
Expand Down

0 comments on commit 5951f95

Please sign in to comment.