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

Do not wrap 'logged out' error #225

Merged
merged 3 commits into from
Apr 2, 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
2 changes: 1 addition & 1 deletion internal/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type app struct {
FirstRuns map[string]bool `json:"first_runs"`
}

var errUnauthenticated = errors.New("Not yet configured. Try `auth0 login`.")
var errUnauthenticated = errors.New("Not logged in. Try 'auth0 login'.")

// cli provides all the foundational things for all the commands in the CLI,
// specifically:
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func logoutCmd(cli *cli) *cobra.Command {
if len(args) == 0 {
tens, err := cli.listTenants()
if err != nil {
return fmt.Errorf("Unable to load tenants due to an unexpected error: %w", err)
return err // This error is already formatted for display
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible for another err other than errUnauthenticated to be returned? Do we need to check that it is that error?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good Q @aherzog-auth0 . It boils down to two other error types:

  • json.Unmarshal
  • os.ReadFile

If we want this to be complete, we can check errUnauthenticated, return it as is, otherwise do an error wrap with Unexpected error: %w type pattern.

What do you think @Widcket ?

}

if len(tens) == 0 {
Expand Down