Unwrap grpc errors to make nicer user facing errors

This commit is contained in:
Kristoffer Dalby 2021-11-07 10:15:32 +00:00
parent b11acad1c9
commit d47b83f80b
4 changed files with 18 additions and 14 deletions

View file

@ -6,6 +6,7 @@ import (
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"google.golang.org/grpc/status"
)
func init() {
@ -80,7 +81,7 @@ var createNodeCmd = &cobra.Command{
response, err := client.DebugCreateMachine(ctx, request)
if err != nil {
ErrorOutput(err, fmt.Sprintf("Cannot create machine: %s", err), output)
ErrorOutput(err, fmt.Sprintf("Cannot create machine: %s", status.Convert(err).Message()), output)
return
}