1 | function captureStackTrace(error) {
|
2 | const container = new Error(); // eslint-disable-line unicorn/error-message
|
3 |
|
4 | Object.defineProperty(error, 'stack', {
|
5 | configurable: true,
|
6 | get() {
|
7 | const {stack} = container;
|
8 | Object.defineProperty(this, 'stack', {value: stack});
|
9 | return stack;
|
10 | },
|
11 | });
|
12 | }
|
13 |
|
14 | export default Error.captureStackTrace ?? captureStackTrace;
|