Skip to content

Commit a3a7b74

Browse files
authored
Fix stringification of AggregateErrors (#1651)
1 parent 8e08f5b commit a3a7b74

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/utils/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ export const exportedUris: Set<string> = new Set();
5252
export const identifierRegex = /^(?:%|\p{L})[\p{L}\d]*$/u;
5353

5454
/**
55-
* Return a string represenattion of `error`.
55+
* Return a string representation of `error`.
5656
* If `error` is `undefined`, returns the empty string.
5757
*/
5858
export function stringifyError(error): string {
5959
try {
60-
if (error instanceof AggregateError) {
61-
// Need to stringify the inner errors
60+
if (Array.isArray(error?.errors)) {
61+
// Need to stringify the inner errors of an AggregateError
6262
const errs = error.errors.map(stringifyError).filter((s) => s != "");
6363
return errs.length ? `AggregateError:\n- ${errs.join("\n- ")}` : "";
6464
}

0 commit comments

Comments
 (0)