mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 20:29:11 +00:00
Prevent customInspect error from crashing console (#3226)
This commit is contained in:
parent
f484776384
commit
2f0f236d56
2 changed files with 26 additions and 2 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue