| 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; | |
| } |