-
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
chore: show human readable errors for toggle flag and fetch environment #170
Merged
sunnyguduru
merged 23 commits into
main
from
sunny/sc-239301/show-human-friendly-error-messages
Apr 18, 2024
Merged
Changes from 20 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
d641792
add human readable errors for toggle flag and fetch environment
25a20a1
handle conflict for toggleFlag
7de9886
make helper function
056fb7d
used handle error on fetchEnv
feb5003
Merge branch 'main' into sunny/sc-239301/show-human-friendly-error-me…
39bef6c
remove handleError. Remove unneeded parameters on message types
3c7b4a8
mend
d83b3f4
add back parameter to createFlag
66a0f92
added back parameter for toggle flag
3a11a7e
rename variable
2a67d50
changed message to remove toggle state
92f3bfb
update create flag
bbd48f6
update toggle flag
653a2a5
undo changes for fetchEnv
b63f681
remove conflict handling on toggle flag cmd
6e7c486
don't show duplicate error on toggle flag
1a14357
show error peroperly on create flag
cefa5ca
fixed create flag
9ea827c
fixed toggle flag
75443f6
remove unused variable from toggle flag
9453365
Merge branch 'main' into sunny/sc-239301/show-human-friendly-error-me…
957e4b9
fix bug
b41e87f
Merge branch 'main' into sunny/sc-239301/show-human-friendly-error-me…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,8 +46,7 @@ func toggleFlag(client flags.Client, accessToken, baseUri, flagKey string, enabl | |
} | ||
|
||
type createdFlagMsg struct { | ||
flag flag | ||
existingFlagUsed bool | ||
flag flag | ||
} | ||
|
||
type confirmedFlagMsg struct { | ||
|
@@ -91,8 +90,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, | ||
|
@@ -122,7 +119,7 @@ func createFlag(client flags.Client, accessToken, baseUri, flagName, flagKey, pr | |
return createdFlagMsg{flag: flag{ | ||
key: flagKey, | ||
name: flagName, | ||
}, existingFlagUsed: existingFlag} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. exisitingFlagUsed wasn't getting used anymore so I removed references to it. |
||
}} | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]) | ||
} | ||
Comment on lines
-95
to
97
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prevent showing the success message when there is an error. |
||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This code path doesn't get run anymore as of PR #179
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.
Seems like that's a bug. Can you add
existingFlag = true
in thecreateFlag
command after checkingif !msgRequestErr.IsConflict()
? That would mean there is an error and it's a conflict error, so we want to set the variable to true.