Repository navigation
Map HTTP 404 to NotFoundError (README example never matched) - #33
Merged
Merged
Conversation
NotFoundError is exported, typed in index.d.ts and imported in the README's error-handling example, but buildHttpError never produced it: a 404 came back as a plain TestingBotError, so 'instanceof NotFoundError' was always false. Map 404 to NotFoundError (still a TestingBotError, so existing catch blocks keep working), add a unit test and document it.
There was a problem hiding this comment.
🟢 Approved
The review records no active issues, with the 404 mapping, preserved response details, tests, and documentation covering the change.
No open issues 🎉
What changed in this PR
Updates HTTP error handling so HTTP 404 responses produce the exported NotFoundError, while preserving the original message, status code, and response data.
Changes:
- Map HTTP 404 responses to
NotFoundError. - Add tests covering error type, inheritance, status, message, and response preservation.
- Document 404 handling in the README error example and status table.
This pull request requires changes.
| File | Summary |
|---|---|
test/errors.test.js |
Verifies the new 404 error mapping and preserved response data. |
README.md |
Documents NotFoundError handling for missing resources. |
lib/http-error.js |
Maps 404 responses to NotFoundError; the constructed error currently uses placeholder resource/id metadata that should be made meaningful. |
Review effort: Lite
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.
Part of https://testingbot-team.atlassian.net/browse/TB-1008 (docs audit: run every SDK README snippet).
README walkthrough result (npm 1.2.0,
node:22-bookworm-slim)37 of 38 README calls work against the live API: browsers, devices, IP ranges, user, tests (all
getTestsforms), test details, tunnels, builds,uploadRemoteFile/getStorageFile/deleteStorageFileof the sample APK, storage list, share hash, screenshots, team, codeless list,getAllTests,getTestStatistics,batchGetTestDetails, and the CLI commandsuser info,tests list,browsers list,devices list|available,config ip-ranges,tunnel list,team info,storage list,lab listand--version.The one failure was
getTests({ ..., build: 'ci-42' }), which 404s only because that build doesn't exist in my account. It is expected.Bug fixed here
The Error Handling section imports
NotFoundErrorfrom the package, and the class is exported and typed inindex.d.ts, but nothing ever threw it:buildHttpErrornow maps 404 toNotFoundError, keeping the server message,statusCodeandresponse. It still extendsTestingBotError, so existingcatchcode keeps working. The README table and example now include 404.Verification
Release needed for npm (1.2.1). That is needs-jochen.