Skip to content

Commit

Permalink
chore: show human readable errors for toggle flag and fetch environme…
Browse files Browse the repository at this point in the history
…nt (#170)
  • Loading branch information
Sunny Guduru authored Apr 18, 2024
1 parent 596f102 commit 4e812c6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion internal/quickstart/create_flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ func (m createFlagModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
case createdFlagMsg:
m.showSuccessView = true
m.existingFlagUsed = msg.existingFlagUsed
m.flag = msg.flag
m.existingFlagUsed = msg.existingFlag
case errMsg:
m.err = msg.err
}
Expand Down
9 changes: 5 additions & 4 deletions internal/quickstart/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ func toggleFlag(client flags.Client, accessToken, baseUri, flagKey string, enabl
}

type createdFlagMsg struct {
flag flag
existingFlagUsed bool
flag flag
existingFlag bool
}

type confirmedFlagMsg struct {
Expand Down Expand Up @@ -92,7 +92,6 @@ func (e msgRequestError) IsConflict() bool {
func createFlag(client flags.Client, accessToken, baseUri, flagName, flagKey, projKey string) tea.Cmd {
return func() tea.Msg {
var existingFlag bool

_, err := client.Create(
context.Background(),
accessToken,
Expand All @@ -116,13 +115,15 @@ func createFlag(client flags.Client, accessToken, baseUri, flagName, flagKey, pr
),
),
}
} else {
existingFlag = true
}
}

return createdFlagMsg{flag: flag{
key: flagKey,
name: flagName,
}, existingFlagUsed: existingFlag}
}, existingFlag: existingFlag}
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/quickstart/toggle_flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (m toggleFlagModel) View() string {
toggle = "ON"
}

if m.flagWasEnabled {
if m.flagWasEnabled && m.err == nil {
furtherInstructions = fmt.Sprintf("\n\nCheck your %s to see the change!", logTypeMap[m.sdkKind])
}

Expand Down

0 comments on commit 4e812c6

Please sign in to comment.