Repository navigation
node errors: mark in ErrorCode.ts the errors that print no [code] bracket in Node #39280
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
Open
robobun
wants to merge
24
commits into
main
Choose a base branch
from
farm/6d573c61/abort-error-tostring
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
94c610d
node errors: only give ERR_* codes the bracketed toString()
robobun a58615f
Make the code property of NodeError instances enumerable
robobun 3e90537
Mint the own code from the table literal and leave Error warnings unt…
robobun ba647b4
test: use a concrete deprecation code in the emitWarning passthrough …
robobun 83a4fe6
Shorten comments
robobun dd20209
Keep the code in NodeError toString independent of this.code
robobun 06af0af
Shorten the errorCodeIs comment
robobun bfd2ee6
Merge branch 'main' into robobun/f4e8da95/enumerable-error-code
robobun d2b6125
node errors: put an own enumerable code on ERR_* errors in one ErrorC…
robobun c72185d
Merge branch 'main' into robobun/f4e8da95/enumerable-error-code
robobun 6c08701
child_process: link the line of Node that stamps the syscall
robobun 947886b
node errors: keep the name of the kind on the per-code prototype
robobun 8438a18
Move the tests of what spawn() throws to child_process-node.test.js
robobun caf19d4
child_process: use the captured Object.hasOwn in the catch of spawn()
robobun 467d736
node errors: give the bracketed toString() only to the rows that are …
robobun 8925793
node errors: mark the rows whose error Node makes in native code only
robobun 0239b50
Merge the earlier head of this branch
robobun 42ce11a
node errors: assert that toString is not an own property and that uti…
robobun 702b049
node errors: mark ERR_CRYPTO_TIMING_SAFE_EQUAL_LENGTH, ERR_DLOPEN_FAI…
robobun 2a27847
node errors: shorter comments at plain() and in the table of built-ins
robobun 8106bf2
node errors: one-line comments at plain() and in the table of built-ins
robobun ce9cf9e
node errors: add a producer of ERR_STRING_TOO_LONG to the fixture, an…
robobun 4d52024
node errors: skip the 2 GiB producer of ERR_STRING_TOO_LONG on a smal…
robobun d6c6f6f
node errors: the test decides once which row the fixture leaves out o…
robobun 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 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| // What it costs to make, throw and catch an error that has a Node `code`, for each way into the table of codes. | ||
| import { EventEmitter } from "node:events"; | ||
| import { join } from "node:path"; | ||
| import { setTimeout as sleep } from "node:timers/promises"; | ||
| import { bench, run } from "../runner.mjs"; | ||
|
|
||
| const emitter = new EventEmitter(); | ||
| const aborted = AbortSignal.abort(); | ||
| const errors = Array.from({ length: 1024 }, () => { | ||
| try { | ||
| Buffer.alloc(-1); | ||
| } catch (e) { | ||
| return e; | ||
| } | ||
| }); | ||
|
|
||
| bench("throw new RangeError() (no code)", () => { | ||
| try { | ||
| throw new RangeError("x"); | ||
| } catch {} | ||
| }); | ||
|
|
||
| bench("Buffer.alloc(-1): ERR_OUT_OF_RANGE from C++", () => { | ||
| try { | ||
| Buffer.alloc(-1); | ||
| } catch {} | ||
| }); | ||
|
|
||
| bench("path.join(1): ERR_INVALID_ARG_TYPE from Rust", () => { | ||
| try { | ||
| join(1); | ||
| } catch {} | ||
| }); | ||
|
|
||
| bench("emitter.on('a', 1): ERR_INVALID_ARG_TYPE from a built-in module", () => { | ||
| try { | ||
| emitter.on("a", 1); | ||
| } catch {} | ||
| }); | ||
|
|
||
| bench("process.cpuUsage({ user: -1 }): the RangeError of ERR_INVALID_ARG_VALUE", () => { | ||
| try { | ||
| process.cpuUsage({ user: -1, system: 0 }); | ||
| } catch {} | ||
| }); | ||
|
|
||
| bench("timers/promises setTimeout with an aborted signal: ABORT_ERR", async () => { | ||
| try { | ||
| await sleep(1, undefined, { signal: aborted }); | ||
| } catch {} | ||
| }); | ||
|
|
||
| let index = 0; | ||
| bench("read error.code", () => { | ||
| return errors[index++ & 1023].code; | ||
| }); | ||
|
|
||
| await run(); |
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
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.