* If error has `framesToPop` property, it means that the * creator tells us the first x frames will be useless * and should be discarded. Typically error from wrapper function * which don't point to the actual location in the developer's code. * * Example: https://github.com/zertosh/invariant/b
(ex: Error & { framesToPop?: unknown })
| 153 | * Example: https://github.com/zertosh/invariant/blob/master/invariant.js#L46 |
| 154 | */ |
| 155 | function getPopFirstTopFrames(ex: Error & { framesToPop?: unknown }): number { |
| 156 | if (typeof ex.framesToPop === 'number') { |
| 157 | return ex.framesToPop; |
| 158 | } |
| 159 | |
| 160 | return 0; |
| 161 | } |
| 162 | |
| 163 | // https://developer.mozilla.org/en-US/docs/WebAssembly/JavaScript_interface/Exception |
| 164 | // @ts-expect-error - WebAssembly.Exception is a valid class |