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

Expose custom error message for 'must change password' #916

Merged
merged 2 commits into from
Sep 8, 2023

Conversation

evankanderson
Copy link
Member

@evankanderson evankanderson commented Sep 8, 2023

Obviously, there are probably a lot more places where we might want to expose these messages.

We'll also need a new medic release to actually print them, because util.ExitNicelyOnError is called in the CLI.

Sample output:

$ go run ./cmd/cli user get                                              
Error getting personal user: Code: 16
Name: UNAUTHENTICATED
Description: Unauthenticated
Details: password change required

I'm thinking of dialing down the verbosity of ExitNicelyOnError, but that seems separate.

And, for good measure, testing a command that should return a blanked error:

$ go run ./cmd/cli user get --id 1  # as non-root user
Error getting user by id: Code: 7
Name: PERMISSION_DENIED
Description: Permission denied
Details: PermissionDenied indicates the caller does not have permission to
execute the specified operation.

JAORMX
JAORMX previously approved these changes Sep 8, 2023
Copy link
Contributor

@JAORMX JAORMX left a comment

Choose a reason for hiding this comment

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

Kiitos!

Comment on lines 65 to 66
ns := NiceStatus{}
ns.SetCode(s.Code())
Copy link
Member

Choose a reason for hiding this comment

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

There seems to be a pattern in the rest of the code to use GetNiceStatus in this scenario.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch! Done!

It turns out that returning NiceStatus instead of *NiceStatus meant that I had to call .String() explicitly later. Now that print call is simpler, too!

@evankanderson evankanderson merged commit a39156c into stacklok:main Sep 8, 2023
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants