parse static method
The frames of stack, in order, innermost first.
Lines the runtime writes that are not frames — <asynchronous suspension> — are skipped. A line that looks like a frame but cannot be
read is kept with its text as the function, so a stack in a format this
does not know still says something rather than nothing.
Implementation
static List<DVCrashFrame> parse(Object stack) {
final List<DVCrashFrame> frames = <DVCrashFrame>[];
for (final String raw in '$stack'.split('\n')) {
final String line = raw.trim();
if (line.isEmpty || line.startsWith('<')) continue;
final RegExpMatch? match = _vmLine.firstMatch(line);
if (match == null) {
frames.add(DVCrashFrame(function: line));
continue;
}
frames.add(DVCrashFrame(
function: match.group(1)!,
uri: match.group(2),
line: int.tryParse(match.group(3) ?? ''),
column: int.tryParse(match.group(4) ?? ''),
));
}
return frames;
}