-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: better flag create error handling #85
Conversation
This pull request has been linked to Shortcut Story #238061: show error response when creating flag in setup wizard. |
var ldErr *ldapi.GenericOpenAPIError | ||
ok := errors.As(err, &ldErr) | ||
// LDAPIError is an error from the LaunchDarkly API client. | ||
type LDAPIError interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't test with GenericOpenAPIError
because it has unexported fields and no constructor function. It does have the shape of this interface so we can implement our own error struct type for tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah good catch ty!
Show a consistent JSON response when there's an error creating flags. Since the LD client doesn't return a body with a 401 response but does in other responses, we need to build our own body so there's always one to show the user.
The user can't re-enter the name yet.