elastic / elastic/ecs-logging-nodejs

[Feature Request] extract `Error.cause` stacks when logging errors

Open
#168 2 comments 4 reactions 0 assignees View on GitHub
agent-nodejs community
Dominant language
JavaScript
Stars
69
Forks
45
PR merge metrics
No merged PRs in 30d

Description

Now that [`Error.cause`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause) is somewhat standard, it's be great if the `cause` chain's stack traces would also be extracted when logging errors, sort of like the default .toString() of exceptions in Java.

From what I could gather in the code, [only `err.stack` is extracted](https://github.com/elastic/ecs-logging-nodejs/blob/main/packages/ecs-helpers/lib/error-formatters.js#L36).

Looking at recent [NodeJS docs](https://nodejs.org/api/errors.html#errorcause), it does look like the internal formatter/inspector already handles the `cause` of an error when printing it.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.