Skip to content

Conversation

@iuioiua
Copy link
Contributor

@iuioiua iuioiua commented Dec 5, 2025

Deno.errors.* are just errors. However, before, a Deno.errors.* constructor wouldn't use the options parameter in the call to the constructor call to the parent class (super()). Now it does.

In other words, the following code used to return undefined and pass a type check. Now, it returns hello and the error's runtime behaviour aligns with its type.

new Deno.errors.NotFound("not found", { cause: "hello" }).cause;

@coderabbitai
Copy link

coderabbitai bot commented Dec 5, 2025

Walkthrough

The pull request updates 22 error class constructors in runtime/js/01_errors.js to accept an opts parameter and forward it to their parent class via the super call. In parallel, the test file tests/unit/error_test.ts is refactored to use a loop-based validation approach with a helper function instead of individual per-constructor assertions, improving test maintainability while preserving test coverage.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: updating Deno.errors constructors to handle the options parameter.
Description check ✅ Passed The description directly explains the fix with a concrete example showing how the options parameter now works correctly in error constructors.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a 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 specificity

The table-driven test plus assertError is a nice, compact way to validate cause across all the error types. To slightly strengthen coverage without much noise, you could also assert that each instance is of the specific constructor, not just Error, 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 subclassing Error correctly or is aliased to the wrong class, while keeping the test simple.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3a4b9de and e5b55df.

📒 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-brk flag and connect Chrome DevTools to chrome://inspect
Use console.log() for debug prints in JavaScript runtime code

Files:

  • tests/unit/error_test.ts
  • runtime/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: Forwarding opts to super looks correct and aligns runtime with ErrorOptions

Changing all these error constructors to constructor(msg, opts) { super(msg, opts); this.name = "…"; } is consistent and should ensure new Deno.errors.X("msg", { cause }) now behaves like the built-in Error with options, without altering existing name/message behavior. I don’t see any functional issues with this pattern across the classes in this file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant