chore: better error handling for commands - #63
Merged
k3llymariee merged 4 commits intoMar 25, 2024
Conversation
|
This pull request has been linked to Shortcut Story #237645: have better error handling for commands. |
k3llymariee
commented
Mar 25, 2024
Comment on lines
+45
to
+49
| var ldErr *ldapi.GenericOpenAPIError | ||
| ok := errors.As(err, &ldErr) | ||
| if ok { | ||
| return nil, NewErrorWrapped(string(ldErr.Body()), ldErr) | ||
| } |
Contributor
Author
There was a problem hiding this comment.
The API should always return errors in a common format per our documentation, so we should be able to rely on the ldapi.GenericOpenAPIError to get the json message body out.
k3llymariee
marked this pull request as ready for review
March 25, 2024 20:00
dbolson
approved these changes
Mar 25, 2024
| }) | ||
| } | ||
|
|
||
| func NewApiError(err error) ([]byte, error) { |
Contributor
There was a problem hiding this comment.
Could you have this return only the error? It's confusing why it also returns a nil byte array.
And could you rename it to NewAPIError?
Contributor
Author
There was a problem hiding this comment.
oops yeah that was a goland refactor thing - and done!
k3llymariee
deleted the
kelly/sc-237645/better-error-handling-for-commands
branch
March 25, 2024 21:53
3 tasks
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds a new error type and error method to handle errors returned by the LD go client, displaying the json response body.
Structural errors like missing flag or invalid commands will still show an error and return usage, logical errors like like invalid access token or project key will show the error but not usage.