Files
bun.sh/test/js/node/v8/error-prepare-stack-default-fixture.js
Jarred Sumner 683a03d8c7 Set a default value for Error.prepareStackTrace to align with Node (#8657)
* Set a default value for `Error.prepareStackTrace` to align with Node

* Ensure we never set negative line/column numbers in error.stack (#8656)

* fix(windows): fix macros (#8653)

* fix macro tests

* path format options

* remove failing comment

* fix buffer toString memcpy length

* Ensure we never set negative line/column numbers in error.stack

---------

Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
2024-02-03 02:04:58 -08:00

24 lines
758 B
JavaScript
Generated

// @bun
// This tests that Error.prepareStackTrace behaves the same when it is set to undefined as when it was never set.
const orig = Error.prepareStackTrace;
Error.prepareStackTrace = (err, stack) => {
return orig(err, stack);
};
const err = new Error();
Error.captureStackTrace(err);
const stack = err.stack;
Error.prepareStackTrace = undefined;
const err2 = new Error();
Error.captureStackTrace(err2);
const stack2 = err2.stack;
const stackIgnoringLineAndColumn = stack2.replaceAll(":16:2", "N");
const stack2IgnoringLineAndColumn = stack.replaceAll(":11:2", "N");
if (stackIgnoringLineAndColumn !== stack2IgnoringLineAndColumn) {
console.log(stackIgnoringLineAndColumn, stack2IgnoringLineAndColumn);
throw new Error("Stacks are different");
}