4

To get as much as possible from my errors, I want to capture stack trace to display in the browser console and also to send it to an external logger service.

The first case works fine, when I console.error(myError) the source map file is interpreted correctly by the browser and the stack trace display relevant file names.

However, when I try to get the stack trace as a string with (new Error()).stack, the filenames are not relevant:

My Error
at applicationError (http://localhost:3000/static/js/main.chunk.js:29259:
at http://localhost:3000/static/js/main.chunk.js:1624:
at onError (http://localhost:3000/static/js/0.chunk.js:82415:3)
at apiCall (http://localhost:3000/static/js/0.chunk.js:82449:12)
at async http://localhost:3000/static/js/main.chunk.js:26165:21
at async App.componentWillMount (http://localhost:3000/static/js/main.chunk.js:246:5)

How can I get the "parsed" stack trace so I can send the relevant information to my logger?

I have seen these SO questions but, while the question seems relevant at first sight, none answer my question:

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
TOPKAT
  • 6,667
  • 2
  • 44
  • 72

0 Answers0