errors: print original exception context
When --enable-source-maps is set, the error context displayed above the stack trace now shows original source rather than transpiled.
When --enable-source-maps
is set, annotate the top of the stack trace with the original source, rather than the ugly transpiled source:
before:
if ((obj === null || obj === void 0 ? void 0 : (_obj$a = obj.a) === null || _obj$a === void 0 ? void 0 : _obj$a.b) === 22) throw Error('an exception');
after:
/Users/bencoe/oss/node-1/test/fixtures/source-map/babel-throw-original.js:18
if (obj?.a?.b === 22) throw Error('an exception');
Open questions
The logic in node_errors.cc
is a little magical to me, specifically I'm trying to figure out how it's placing the ^
under the throw
, rather than under the Error
(which is where the stack trace points).
@addaleax I know you've also worked in this file, any thoughts (maybe this is an issue we don't care about).
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
documentation is changed or added -
commit message follows commit guidelines