Skip to content

Commit

Permalink
Fix inspection of MatterAggregateError (#1557)
Browse files Browse the repository at this point in the history
  • Loading branch information
lauckhart authored Dec 25, 2024
1 parent e22bd24 commit 0f5b0fe
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/general/src/MatterError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class MatterError extends Error {
/**
* Convert the error to formatted text.
*
* Matter encodes errors with modern JS features including {@link Error#cause} and {@link AggregateError#errors}
* matter.js encodes errors with modern JS features including {@link Error#cause} and {@link AggregateError#errors}
* subfields. You can use this function to ensure all error details are presented regardless of environment.
*/
format(format: "plain" | "ansi" | "html" = "plain", indents = 0) {
Expand Down Expand Up @@ -142,10 +142,10 @@ export class MatterAggregateError extends AggregateError {
constructor(causes: Iterable<unknown>, message?: string) {
causes = [...causes].map(errorOf);
super(causes, message);
}

[inspect] = MatterError.prototype[inspect];
format = MatterError.prototype.format;
Object.defineProperty(MatterAggregateError.prototype, inspect, { enumerable: false });
Object.defineProperty(MatterAggregateError.prototype, "format", { enumerable: false });
}

// TODO - see comment on MatterError. If that one is correct this is incorrect
static override [Symbol.hasInstance](instance: unknown) {
Expand All @@ -156,6 +156,11 @@ export class MatterAggregateError extends AggregateError {
}
}

Object.assign(MatterAggregateError, {
[inspect]: MatterError.prototype[inspect],
format: MatterError.prototype.format,
});

/**
* It's never reasonable to fail to present error information so we include this rudimentary fallback error formatter.
*/
Expand Down

0 comments on commit 0f5b0fe

Please sign in to comment.