apm-agent-nodejs icon indicating copy to clipboard operation
apm-agent-nodejs copied to clipboard

Look into supporting chained exceptions

Open watson opened this issue 6 years ago • 3 comments

We're adding support for chained exceptions in Elastic APM (see elastic/apm#40).

However, we don't have a way to chain in exceptions in Node.js, but I was thinking we might provide an API that allows the user to record such things.

E.g. it's not uncommon in Node.js to say get a low-level error back from the database driver and then throw a more high-level error. Having access to both the low and the high-level error would be useful.

watson avatar Jul 05 '19 08:07 watson

I’ve seen multiple libraries for chaining exceptions implement err.cause() to receive the low level error from the high level error.

I’ve also seen logging libraries detect for that method and using it in their error pretty printing.

Raynos avatar Sep 10 '19 10:09 Raynos

Food for thought: https://github.com/tc39/proposal-error-cause

trentm avatar Jun 07 '21 19:06 trentm

With error cause being in Stage 4 perhaps it is time to support this?

kasper573 avatar Aug 21 '25 16:08 kasper573