Skip to content

Commit d16f595

Browse files
committed
fix(logger): handle errors correctly
1 parent f4cfb92 commit d16f595

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

logger/_logger.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,12 +340,13 @@ export class Logger<T extends Record<PropertyKey, unknown> = {}> {
340340
* When running on Deno, this method will use the `Deno.inspect` method.
341341
*/
342342
#inspect(value: unknown, { tag = false } = {}) {
343+
const error = value && (value instanceof Error) ? value : null
343344
value = this.#censor(value)
344345
switch (true) {
345346
case !tag && typeof value === "string":
346347
return value
347-
case value && value instanceof Error:
348-
return red(value.stack || value.message)
348+
case error !== null:
349+
return red(this.#censor_string(error.stack ?? error.message))
349350
default:
350351
return globalThis.Deno?.inspect(value, { colors: true, depth: Infinity, strAbbreviateSize: Infinity }) ?? value
351352
}

0 commit comments

Comments
 (0)