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: Show error along with message and quit if applicable #87

Merged
merged 3 commits into from
Mar 29, 2024

Conversation

dbolson
Copy link
Contributor

@dbolson dbolson commented Mar 28, 2024

Show a "helpful" error message if the response is such that the user couldn't continue the setup flow.

This will print out eg.,

You lack access to complete this action. Try authenticating with elevated access or speak to a LaunchDarkly account administrator.

{"message":"Access to the requested resource was denied","reason":{"effect":"deny"},"access":{"action":"createFlag","resource":"proj/default:env/test:flag/my-new-flag"},"code":"forbidden"}

Copy link

This pull request has been linked to Shortcut Story #238061: show error response when creating flag in setup wizard.

@@ -49,13 +50,20 @@ func (m ContainerModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case key.Matches(msg, keys.Enter):
switch m.currentStep {
case createFlagStep:
updated, _ := m.steps[createFlagStep].Update(msg)
updated, cmd := m.steps[createFlagStep].Update(msg)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Delegates the tea.Quit command. Seems cleaner?

Copy link
Contributor

Choose a reason for hiding this comment

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

feels like we should leverage that functionality as much as possible!

@@ -69,6 +72,18 @@ func (m createFlagModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
)
if err != nil {
m.err = err
// TODO: we may want a more robust error type so we don't need to do this
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Once we add more steps I'll refactor this.

@@ -49,13 +50,20 @@ func (m ContainerModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case key.Matches(msg, keys.Enter):
switch m.currentStep {
case createFlagStep:
updated, _ := m.steps[createFlagStep].Update(msg)
updated, cmd := m.steps[createFlagStep].Update(msg)
Copy link
Contributor

Choose a reason for hiding this comment

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

feels like we should leverage that functionality as much as possible!

@dbolson dbolson merged commit f076a59 into main Mar 29, 2024
2 checks passed
@dbolson dbolson deleted the sc-238061/flag-create-error-handling-quit branch March 29, 2024 17:38
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