File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -560,6 +560,12 @@ JSON-serializable will cause an error at log time:
560560* Functions are silently omitted by `JSON.stringify()`.
561561* Circular references throw a `TypeError`.
562562
563+ `Error` objects are an exception to this rule. Although `JSON.stringify()`
564+ serializes `Error` instances as `' {}' ` (because their properties are
565+ non-enumerable), the logger handles them automatically using the built-in
566+ [`stdSerializers.err()`][] serializer, which extracts `type`, `message`,
567+ `stack`, and the `cause` chain.
568+
563569To log `BigInt` values, convert them to strings or numbers first:
564570
565571```js
@@ -898,4 +904,5 @@ consumer.attach();
898904` ` `
899905
900906[RFC 5424 ]: https: // www.rfc-editor.org/rfc/rfc5424.html
907+ [` stdSerializers.err()` ]: #stdserializerserrerror
901908[` util.inspect.custom` ]: util .md #utilinspectcustom
You can’t perform that action at this time.
0 commit comments