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

feat: better flag create error handling #85

Merged
merged 5 commits into from
Mar 28, 2024

Conversation

dbolson
Copy link
Contributor

@dbolson dbolson commented Mar 28, 2024

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.

Screenshot 2024-03-28 at 10 00 17 AM Screenshot 2024-03-28 at 9 59 53 AM Screenshot 2024-03-28 at 9 59 40 AM

Copy link

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 {
Copy link
Contributor Author

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.

Copy link
Contributor

@k3llymariee k3llymariee left a 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!

@dbolson dbolson merged commit 708925b into main Mar 28, 2024
4 checks passed
@dbolson dbolson deleted the sc-238061/flag-create-error-handling branch March 28, 2024 18:23
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.

2 participants