(raw: string)
| 180 | } |
| 181 | |
| 182 | function remapStack(raw: string): string { |
| 183 | const lines = raw.split('\n'); |
| 184 | const out = lines.map((line) => { |
| 185 | // 1) Parenthesized frame: at fn (file:...:L:C) |
| 186 | let m = /\((.+):(\d+):(\d+)\)/.exec(line); |
| 187 | if (m) { |
| 188 | try { |
| 189 | const [_, file, l, c] = m; |
| 190 | const orig = remapFrame(file, +l, +c); |
| 191 | if (!orig.source) return line; |
| 192 | return line.replace(/\(.+\)/, `(${orig.source}:${orig.line}:${orig.column})`); |
| 193 | } catch (error) { |
| 194 | console.debug && console.debug('Remap failed for frame:', line, error); |
| 195 | return line; |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | // 2) Bare frame: at file:///app/vendor.js:L:C (no parentheses) |
| 200 | const bare = /(\s+at\s+)([^\s()]+):(\d+):(\d+)/.exec(line); |
| 201 | if (bare) { |
| 202 | try { |
| 203 | const [, prefix, file, l, c] = bare; |
| 204 | const orig = remapFrame(file, +l, +c); |
| 205 | if (!orig.source) return line; |
| 206 | const replacement = `${prefix}${orig.source}:${orig.line}:${orig.column}`; |
| 207 | return line.replace(bare[0], replacement); |
| 208 | } catch (error) { |
| 209 | console.debug && console.debug('Remap failed for bare frame:', line, error); |
| 210 | return line; |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | return line; |
| 215 | }); |
| 216 | return out.join('\n'); |
| 217 | } |
| 218 | |
| 219 | /** |
| 220 | * Added with 9.0 runtimes. |
no test coverage detected