| 86 | } |
| 87 | |
| 88 | function parseStackFrames(frames) { |
| 89 | let stop = false; |
| 90 | let ret = []; |
| 91 | frames.some(frame => { |
| 92 | if (stop) { |
| 93 | return true; |
| 94 | } |
| 95 | |
| 96 | let m; |
| 97 | |
| 98 | /* eslint-disable max-len */ |
| 99 | if (m = frame.match(/^\s*at\s*((new )?.+?)\s*(\[as\s*([^\]]*)\]\s*)?\((.*?)(:(\d+))?(:(\d+))?\)\s*$/)) { |
| 100 | // https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi |
| 101 | // " at My.Function (/path/to/myfile.js:532:39)" |
| 102 | // " at Array.forEach (native)" |
| 103 | // " at new My.Class (file.js:1:2)" |
| 104 | // " at [object Object].main.registerCommand.name [as func] (meteor/tools/commands.js:1225:19)" |
| 105 | // " at __top_mark__ [as matchErr] (meteor/tools/parse-stack.js:82:14)" |
| 106 | // |
| 107 | // In that last example, it is not at all clear to me what the |
| 108 | // 'as' stanza refers to, but it is in m[3] if you find a use for it. |
| 109 | if (m[1].match(/(?:^|\.)__top_mark__$/)) { |
| 110 | // m[1] could be Object.__top_mark__ or something like that |
| 111 | // depending on where exactly you put the function returned by |
| 112 | // markTop |
| 113 | ret = []; |
| 114 | return; |
| 115 | } |
| 116 | if (m[1].match(/(?:^|\.)__bottom_mark__$/)) { |
| 117 | return stop = true; |
| 118 | } |
| 119 | ret.push({ |
| 120 | func: m[1], |
| 121 | file: m[5], |
| 122 | line: m[7] ? +m[7] : undefined, |
| 123 | column: m[9] ? +m[9] : undefined |
| 124 | }); |
| 125 | return; |
| 126 | } |
| 127 | /* eslint-enable max-len */ |
| 128 | |
| 129 | if (m = frame.match(/^\s*at\s+(.+?)(:(\d+))?(:(\d+))?\s*$/)) { |
| 130 | // " at /path/to/myfile.js:532:39" |
| 131 | ret.push({ |
| 132 | file: m[1], |
| 133 | line: m[3] ? +m[3] : undefined, |
| 134 | column: m[5] ? +m[5] : undefined |
| 135 | }); |
| 136 | return; |
| 137 | } |
| 138 | |
| 139 | if (m = frame.match(/^\s*-\s*-\s*-\s*-\s*-\s*$/)) { |
| 140 | // Stop parsing if we reach a stack split from a Future |
| 141 | return stop = true; |
| 142 | } |
| 143 | |
| 144 | if (frame.startsWith(" => awaited here:")) { |
| 145 | // The meteor-promise library inserts " => awaited here:" lines to |