(label)
| 7 | * @returns {Error & { stack: string } | null} |
| 8 | */ |
| 9 | export function get_error(label) { |
| 10 | const error = new Error(); |
| 11 | const stack = get_stack(); |
| 12 | |
| 13 | if (stack.length === 0) { |
| 14 | return null; |
| 15 | } |
| 16 | |
| 17 | stack.unshift('\n'); |
| 18 | |
| 19 | define_property(error, 'stack', { |
| 20 | value: stack.join('\n') |
| 21 | }); |
| 22 | |
| 23 | define_property(error, 'name', { |
| 24 | value: label |
| 25 | }); |
| 26 | |
| 27 | return /** @type {Error & { stack: string }} */ (error); |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * @returns {string[]} |