Make use of asError instead of reimplementing#1997
Merged
robertbrignull merged 2 commits intomainfrom Jan 23, 2023
Merged
Conversation
koesie10
reviewed
Jan 23, 2023
Member
koesie10
left a comment
There was a problem hiding this comment.
Thanks for cleaning this up!
Comment on lines
+775
to
+774
| err.message = `Error running query: ${err.message}`; | ||
| item.failureReason = err.message; | ||
| item.failureReason = `Error running query: ${getErrorMessage(e)}`; |
Member
There was a problem hiding this comment.
This changes behaviour for the thrown error since the error message now doesn't include Error running query:. The message from the error is probably shown to the user directly since this method is called by a command, so this might change user-facing behaviour as well (depending on if the thrown error is an instance of Error).
Contributor
Author
There was a problem hiding this comment.
Oh your right because asError can just return e instead of a new error, so actually this does edit the existing e which we later throw 🤯
I'll revert this change and leave this file alone.
koesie10
approved these changes
Jan 23, 2023
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.
This PR updates a few places that were doing their own
e instanceOf Errorcheck to instead useasErrororgetErrorMessageas appropriate.Also updates the types of the helper methods to be more restrictive, as I believe using
unknowninstead ofanywhere possible is generally best practice. I haven't gone any further than this with annotating things asunknownto avoid going down too much of a rabbit hole.Checklist
ready-for-doc-reviewlabel there.