blob: f999f39c8bfbfd00829592518fa9dfc1706b9ca8 [file] [log] [blame] [edit]
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
try {
a();
} catch (e) {
if (e.stack.split("\n").length !== 2)
throw e;
}