Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add auth0.Error [CLI-156] #285

Merged
merged 1 commit into from
May 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ require (
github.com/mholt/archiver/v3 v3.5.0
github.com/olekukonko/tablewriter v0.0.5
github.com/pierrec/lz4/v4 v4.1.3 // indirect
github.com/pkg/errors v0.9.1
github.com/rivo/uniseg v0.2.0 // indirect
github.com/spf13/cobra v1.1.3
github.com/spf13/pflag v1.0.5
Expand Down
3 changes: 2 additions & 1 deletion internal/ansi/spinner.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"os"
"time"

"github.com/auth0/auth0-cli/internal/auth0"
"github.com/briandowns/spinner"
)

Expand Down Expand Up @@ -40,7 +41,7 @@ func loading(initialMsg, doneMsg, failMsg string, fn func() error) error {
s.Writer = os.Stderr

if err := s.Color(spinnerColor); err != nil {
panic(err)
panic(auth0.Error(err, "failed setting spinner color"))
}

s.Start()
Expand Down
7 changes: 7 additions & 0 deletions internal/auth0/error.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package auth0

import "github.com/pkg/errors"

func Error(e error, message string) error {
return errors.Wrap(e, message)
}
9 changes: 5 additions & 4 deletions internal/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"

"github.com/AlecAivazis/survey/v2"
"github.com/auth0/auth0-cli/internal/auth0"
"github.com/auth0/auth0-cli/internal/prompt"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -209,31 +210,31 @@ func registerString(cmd *cobra.Command, f *Flag, value *string, defaultValue str
cmd.Flags().StringVarP(value, f.LongForm, f.ShortForm, defaultValue, f.Help)

if err := markFlagRequired(cmd, f, isUpdate); err != nil {
panic(unexpectedError(err)) // TODO: Handle
panic(auth0.Error(err, "failed to register string flag"))
}
}

func registerStringSlice(cmd *cobra.Command, f *Flag, value *[]string, defaultValue []string, isUpdate bool) {
cmd.Flags().StringSliceVarP(value, f.LongForm, f.ShortForm, defaultValue, f.Help)

if err := markFlagRequired(cmd, f, isUpdate); err != nil {
panic(unexpectedError(err)) // TODO: Handle
panic(auth0.Error(err, "failed to register string slice flag"))
}
}

func registerInt(cmd *cobra.Command, f *Flag, value *int, defaultValue int, isUpdate bool) {
cmd.Flags().IntVarP(value, f.LongForm, f.ShortForm, defaultValue, f.Help)

if err := markFlagRequired(cmd, f, isUpdate); err != nil {
panic(unexpectedError(err)) // TODO: Handle
panic(auth0.Error(err, "failed to register int flag"))
}
}

func registerBool(cmd *cobra.Command, f *Flag, value *bool, defaultValue bool, isUpdate bool) {
cmd.Flags().BoolVarP(value, f.LongForm, f.ShortForm, defaultValue, f.Help)

if err := markFlagRequired(cmd, f, isUpdate); err != nil {
panic(unexpectedError(err)) // TODO: Handle
panic(auth0.Error(err, "failed to register bool flag"))
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/cli/quickstarts.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var (
qsBuf []byte
quickstartsByType = func() (qs map[string][]auth0.Quickstart) {
if err := json.Unmarshal(qsBuf, &qs); err != nil {
panic(err)
panic(auth0.Error(err, "failed to unmarshal data/quickstarts.json"))
}
return
}()
Expand Down
1 change: 1 addition & 0 deletions vendor/modules.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.