Skip to content

Conversation

@Tango992
Copy link
Member

@Tango992 Tango992 commented Jan 28, 2026

Towards #29801

Gives better error formating based on Node's implementation, especially on AggregateError instance / nested errors. This in turn allows test/parallel/test-assert-deep-with-error.js to pass.

Given this code:

class CustomError extends Error {
  constructor(message) {
    super(message);
    this.name = "CustomError";
    this.cause = new Error("This is the cause of the CustomError.");
  }
}

const aggregateError = new AggregateError([
  new CustomError("Error message 1."),
  new Error("Error message 2."),
], "Multiple errors.");
console.log(aggregateError);

Deno v2.6.7 outputs:

AggregateError: Multiple errors.
    CustomError: Error message 1.
        at file:///index.js:10:3
    Caused by Error: This is the cause of the CustomError.
        at new CustomError (file:///index.js:5:18)
        at file:///index.js:10:3 {
      name: "CustomError"
    }
    Error: Error message 2.
        at file:///index.js:11:3
    at file:///index.js:9:24

This PR outputs:

AggregateError: Multiple errors.
    at file:///index.js:9:24 {
  [errors]: [
    CustomError: Error message 1.
        at file:///index.js:10:3 {
      cause: Error: This is the cause of the CustomError.
          at new CustomError (file:///index.js:5:18)
          at file:///index.js:10:3
    },
    Error: Error message 2.
        at file:///index.js:11:3
  ]
}

@Tango992 Tango992 changed the title fix(ext/node): inspect error fix(ext/node): inspect error compatibility Jan 28, 2026
@Tango992 Tango992 changed the title fix(ext/node): inspect error compatibility fix(ext/node): error formatting compatibility Jan 31, 2026
@Tango992 Tango992 marked this pull request as ready for review January 31, 2026 07:21
Copy link
Member

@crowlKats crowlKats left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Tango992 Tango992 merged commit 7c5447f into denoland:main Feb 2, 2026
41 of 42 checks passed
@Tango992 Tango992 deleted the inspect-error branch February 2, 2026 09:45
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.

2 participants