Unverified Commit 46b1b677 authored by Yegor's avatar Yegor Committed by GitHub

fix stack frame parser (#69253)

parent e5c4c4b2
......@@ -211,7 +211,9 @@ class StackFrame {
String className = '';
String method = match.group(2)!.replaceAll('.<anonymous closure>', '');
if (method.startsWith('new')) {
className = method.split(' ')[1];
final List<String> methodParts = method.split(' ');
// Sometimes a web frame will only read "new" and have no class name.
className = methodParts.length > 1 ? method.split(' ')[1] : '<unknown>';
method = '';
if (className.contains('.')) {
final List<String> parts = className.split('.');
......
......@@ -81,6 +81,24 @@ void main() {
expect('$e', contains('Got a stack frame from package:stack_trace'));
}
});
test('Can parse web constructor invocation with unknown class name', () {
const String stackTraceLine = '#32 new (http://localhost:42191/dart-sdk/lib/async/stream_controller.dart:880:9)';
expect(
StackFrame.fromStackTraceLine(stackTraceLine),
const StackFrame(
number: 32,
className: '<unknown>',
method: '',
packageScheme: 'http',
package: '<unknown>',
packagePath: 'dart-sdk/lib/async/stream_controller.dart',
line: 880,
column: 9,
source: stackTraceLine,
),
);
});
}
const String stackString = '''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment