From 2f0f236d5656fa2d89a8e1571d03c4bda5f10d38 Mon Sep 17 00:00:00 2001 From: "Kevin (Kun) \"Kassimo\" Qian" Date: Mon, 28 Oct 2019 15:29:15 -0700 Subject: Prevent customInspect error from crashing console (#3226) --- cli/js/console.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'cli/js/console.ts') diff --git a/cli/js/console.ts b/cli/js/console.ts index 9f0ce4bd6..e6b54d8c1 100644 --- a/cli/js/console.ts +++ b/cli/js/console.ts @@ -327,8 +327,11 @@ function createObjectString( ...args: [ConsoleContext, number, number] ): string { if (customInspect in value && typeof value[customInspect] === "function") { - return String(value[customInspect]!()); - } else if (value instanceof Error) { + try { + return String(value[customInspect]!()); + } catch {} + } + if (value instanceof Error) { return String(value.stack); } else if (Array.isArray(value)) { return createArrayString(value, ...args); -- cgit v1.2.3