fix stack frame parser (#69253)
This commit is contained in:
parent
e5c4c4b27a
commit
46b1b67797
@ -211,7 +211,9 @@ class StackFrame {
|
|||||||
String className = '';
|
String className = '';
|
||||||
String method = match.group(2)!.replaceAll('.<anonymous closure>', '');
|
String method = match.group(2)!.replaceAll('.<anonymous closure>', '');
|
||||||
if (method.startsWith('new')) {
|
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 = '';
|
method = '';
|
||||||
if (className.contains('.')) {
|
if (className.contains('.')) {
|
||||||
final List<String> parts = className.split('.');
|
final List<String> parts = className.split('.');
|
||||||
|
@ -81,6 +81,24 @@ void main() {
|
|||||||
expect('$e', contains('Got a stack frame from package:stack_trace'));
|
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 = '''
|
const String stackString = '''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user