4

Since July 2021 they have added a new error cause property in Javascript, so we are able to do:

throw new Error('New error message', { cause: err });

In Firefox this err object is shown after the original error. On Chrome only the original error is shown, and I can't store the thrown error into variable to inspect it. How do I see the error cause then? (Without modifying the source code / get into the debugger)

Gnut
  • 541
  • 1
  • 5
  • 19

1 Answers1

7

I don’t think there's a way unless you catch the error before it's being thrown with the "Pause debugger on uncaught errors".

We'll have to wait until Chrome natively includes the cause’s stack trace in when displaying the error, just like Firefox and Node do. This is being tracked here:

https://bugs.chromium.org/p/chromium/issues/detail?id=1211260

fregante
  • 29,050
  • 14
  • 119
  • 159