fix: respond to 404 errors when checking releases, and fall back to tags #171
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.
Fixes #158
code
404 and an empty response if the release was missing, similar to what happens if you call the GitHub API directly withcurl
. However, this client library we're using (which is not the standard one) actually returns an error object for this case. Unfortunately I could not find any definitions for the type of Error object they're using, but after trial and error we determined the error does have a property calledstatusCode
that we can check. If it's 404 then we just continue to the next tag, if it's another error then we'll throw the error, but it will be caught by step 1 and we'll fall back to tags.replyWithError
to more closely match how the API behaves in reality.write-message
. If this method catches an error that isn't aWombatServerError
then it would just say "unknown error." Now, it can handle eitherWombatServerError
or just regularError
(which has amessage
property not astatusMessage
property) but still returns an error with the same shape (before, it was just an object that had the same properties as WombatSeverError, now it will be an actual instance of it). I tested this change by causing a generic error by not providing all of the mocked API responses tonock
in a test. Previously, the error message would be a cryptic "unknown error" and now the error actually contains the useful message fromnock
. This isn't directly related to the core issue I was facing but it made it easier to debug after I fixed this.I tested this change by actually using this GitHub client library in a separate test program and observing it worked the way I wanted it to. See this gist which I invoked using
node index.js
which actually performs the GH API call (instead of relying on unit tests with mocked API responses). So I am reasonably confident this change works as intended now.