From 0f5b0fe8757984cf3b7f9f5dbf056213852b9f68 Mon Sep 17 00:00:00 2001 From: lauckhart Date: Wed, 25 Dec 2024 04:05:34 -0800 Subject: [PATCH] Fix inspection of MatterAggregateError (#1557) --- packages/general/src/MatterError.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/general/src/MatterError.ts b/packages/general/src/MatterError.ts index c92e666225..90231a2655 100644 --- a/packages/general/src/MatterError.ts +++ b/packages/general/src/MatterError.ts @@ -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) { @@ -142,10 +142,10 @@ export class MatterAggregateError extends AggregateError { constructor(causes: Iterable, 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) { @@ -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. */