-
Notifications
You must be signed in to change notification settings - Fork 5.8k
fix(runtime): handle options parameter in Deno.errors.* constructors
#31510
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe pull request updates 22 error class constructors in Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
tests/unit/error_test.ts (1)
2-47: Good consolidation of error tests; consider one extra assertion for specificityThe table-driven test plus
assertErroris a nice, compact way to validatecauseacross all the error types. To slightly strengthen coverage without much noise, you could also assert that each instance is of the specific constructor, not justError, e.g.:function assertError(ErrorConstructor: typeof Deno.errors.NotFound) { const error = new ErrorConstructor("msg", { cause: "cause" }); assertInstanceOf(error, ErrorConstructor); assertInstanceOf(error, Error); assertEquals(error.cause, "cause"); }This would catch any future wiring mistakes where a given
Deno.errors.*stops subclassingErrorcorrectly or is aliased to the wrong class, while keeping the test simple.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
runtime/js/01_errors.js(1 hunks)tests/unit/error_test.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx,js}: For JavaScript runtime debugging, enable V8 inspector with--inspect-brkflag and connect Chrome DevTools tochrome://inspect
Useconsole.log()for debug prints in JavaScript runtime code
Files:
tests/unit/error_test.tsruntime/js/01_errors.js
🧬 Code graph analysis (1)
runtime/js/01_errors.js (1)
cli/tsc/dts/lib.deno.ns.d.ts (21)
ConnectionRefused(191-191)ConnectionReset(198-198)ConnectionAborted(204-204)NotConnected(209-209)AddrInUse(215-215)AddrNotAvailable(221-221)BrokenPipe(229-229)AlreadyExists(235-235)InvalidData(241-241)TimedOut(247-247)WriteZero(266-266)WouldBlock(260-260)UnexpectedEof(272-272)Http(284-284)Busy(290-290)PermissionDenied(185-185)NotSupported(296-296)FilesystemLoop(302-302)IsADirectory(307-307)NetworkUnreachable(313-313)NotADirectory(319-319)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
- GitHub Check: bench release linux-x86_64
- GitHub Check: test debug macos-x86_64
- GitHub Check: test debug windows-x86_64
- GitHub Check: test debug linux-x86_64
- GitHub Check: test debug macos-aarch64
- GitHub Check: lint debug linux-x86_64
- GitHub Check: build libs
- GitHub Check: lint debug windows-x86_64
- GitHub Check: lint debug macos-x86_64
🔇 Additional comments (1)
runtime/js/01_errors.js (1)
7-159: Forwardingoptstosuperlooks correct and aligns runtime with ErrorOptionsChanging all these error constructors to
constructor(msg, opts) { super(msg, opts); this.name = "…"; }is consistent and should ensurenew Deno.errors.X("msg", { cause })now behaves like the built-inErrorwith options, without altering existing name/message behavior. I don’t see any functional issues with this pattern across the classes in this file.
Deno.errors.*are just errors. However, before, aDeno.errors.*constructor wouldn't use theoptionsparameter in the call to the constructor call to the parent class (super()). Now it does.In other words, the following code used to return
undefinedand pass a type check. Now, it returnshelloand the error's runtime behaviour aligns with its type.