mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
803a7b2b23
The source context is not prepended to the value of the `stack` property when the source map is not enabled. Rather than prepending the error source context to the value of the `stack` property unconditionally, this patch aligns the behavior and only prints the source context when the error is not handled by userland (e.g. fatal errors). Also, this patch fixes that when source-map support is enabled, the error source context is not pointing to where the error was thrown. PR-URL: https://github.com/nodejs/node/pull/43875 Fixes: https://github.com/nodejs/node/issues/43186 Fixes: https://github.com/nodejs/node/issues/41541 Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
18 lines
702 B
TypeScript
18 lines
702 B
TypeScript
'use strict';
|
|
|
|
// Compile with `tsc --inlineSourceMap benchmark/fixtures/simple-error-stack.ts`.
|
|
|
|
const lorem = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';
|
|
|
|
function simpleErrorStack() {
|
|
try {
|
|
(lorem as any).BANG();
|
|
} catch (e) {
|
|
return e.stack;
|
|
}
|
|
}
|
|
|
|
export {
|
|
simpleErrorStack,
|
|
};
|