StackTrace parser, fix assertion error message (#48343)
This commit is contained in:
parent
4552724f0e
commit
505af78ae1
@ -52,5 +52,6 @@ export 'src/foundation/platform.dart';
|
||||
export 'src/foundation/print.dart';
|
||||
export 'src/foundation/profile.dart';
|
||||
export 'src/foundation/serialization.dart';
|
||||
export 'src/foundation/stack_frame.dart';
|
||||
export 'src/foundation/synchronous_future.dart';
|
||||
export 'src/foundation/unicode.dart';
|
||||
|
@ -8,6 +8,7 @@ import 'basic_types.dart';
|
||||
import 'constants.dart';
|
||||
import 'diagnostics.dart';
|
||||
import 'print.dart';
|
||||
import 'stack_frame.dart';
|
||||
|
||||
/// Signature for [FlutterError.onError] handler.
|
||||
typedef FlutterExceptionHandler = void Function(FlutterErrorDetails details);
|
||||
@ -418,39 +419,31 @@ class FlutterErrorDetails extends Diagnosticable {
|
||||
}
|
||||
}
|
||||
|
||||
final Iterable<String> stackLines = (stack != null) ? stack.toString().trimRight().split('\n') : null;
|
||||
if (exception is AssertionError && diagnosticable == null) {
|
||||
bool ourFault = true;
|
||||
if (stackLines != null) {
|
||||
final List<String> stackList = stackLines.take(2).toList();
|
||||
if (stackList.length >= 2) {
|
||||
// TODO(ianh): This has bitrotted and is no longer matching. https://github.com/flutter/flutter/issues/4021
|
||||
final RegExp throwPattern = RegExp(
|
||||
r'^#0 +_AssertionError._throwNew \(dart:.+\)$');
|
||||
final RegExp assertPattern = RegExp(
|
||||
r'^#1 +[^(]+ \((.+?):([0-9]+)(?::[0-9]+)?\)$');
|
||||
if (throwPattern.hasMatch(stackList[0])) {
|
||||
final Match assertMatch = assertPattern.firstMatch(stackList[1]);
|
||||
if (assertMatch != null) {
|
||||
assert(assertMatch.groupCount == 2);
|
||||
final RegExp ourLibraryPattern = RegExp(r'^package:flutter/');
|
||||
ourFault = ourLibraryPattern.hasMatch(assertMatch.group(1));
|
||||
}
|
||||
}
|
||||
if (stack != null) {
|
||||
if (exception is AssertionError && diagnosticable == null) {
|
||||
// After popping off any dart: stack frames, are there at least two more
|
||||
// stack frames coming from package flutter?
|
||||
//
|
||||
// If not: Error is in user code (user violated assertion in framework).
|
||||
// If so: Error is in Framework. We either need an assertion higher up
|
||||
// in the stack, or we've violated our own assertions.
|
||||
final List<StackFrame> stackFrames = StackFrame.fromStackTrace(stack)
|
||||
.skipWhile((StackFrame frame) => frame.packageScheme == 'dart')
|
||||
.toList();
|
||||
final bool ourFault = stackFrames.length >= 2
|
||||
&& stackFrames[0].package == 'flutter'
|
||||
&& stackFrames[1].package == 'flutter';
|
||||
if (ourFault) {
|
||||
properties.add(ErrorSpacer());
|
||||
properties.add(ErrorHint(
|
||||
'Either the assertion indicates an error in the framework itself, or we should '
|
||||
'provide substantially more information in this error message to help you determine '
|
||||
'and fix the underlying cause.\n'
|
||||
'In either case, please report this assertion by filing a bug on GitHub:\n'
|
||||
' https://github.com/flutter/flutter/issues/new?template=BUG.md'
|
||||
));
|
||||
}
|
||||
}
|
||||
if (ourFault) {
|
||||
properties.add(ErrorSpacer());
|
||||
properties.add(ErrorHint(
|
||||
'Either the assertion indicates an error in the framework itself, or we should '
|
||||
'provide substantially more information in this error message to help you determine '
|
||||
'and fix the underlying cause.\n'
|
||||
'In either case, please report this assertion by filing a bug on GitHub:\n'
|
||||
' https://github.com/flutter/flutter/issues/new?template=BUG.md'
|
||||
));
|
||||
}
|
||||
}
|
||||
if (stack != null) {
|
||||
properties.add(ErrorSpacer());
|
||||
properties.add(DiagnosticsStackTrace('When the exception was thrown, this was the stack', stack, stackFilter: stackFilter));
|
||||
}
|
||||
@ -672,39 +665,27 @@ class FlutterError extends Error with DiagnosticableTreeMixin implements Asserti
|
||||
/// format but the frame numbers will not be consecutive (frames are elided)
|
||||
/// and the final line may be prose rather than a stack frame.
|
||||
static Iterable<String> defaultStackFilter(Iterable<String> frames) {
|
||||
const List<String> filteredPackages = <String>[
|
||||
const Set<String> filteredPackages = <String>{
|
||||
'dart:async-patch',
|
||||
'dart:async',
|
||||
'package:stack_trace',
|
||||
];
|
||||
const List<String> filteredClasses = <String>[
|
||||
};
|
||||
const Set<String> filteredClasses = <String>{
|
||||
'_AssertionError',
|
||||
'_FakeAsync',
|
||||
'_FrameCallbackEntry',
|
||||
];
|
||||
final RegExp stackParser = RegExp(r'^#[0-9]+ +([^.]+).* \(([^/\\]*)[/\\].+:[0-9]+(?::[0-9]+)?\)$');
|
||||
final RegExp packageParser = RegExp(r'^([^:]+):(.+)$');
|
||||
};
|
||||
final List<String> result = <String>[];
|
||||
final List<String> skipped = <String>[];
|
||||
for (final String line in frames) {
|
||||
final Match match = stackParser.firstMatch(line);
|
||||
if (match != null) {
|
||||
assert(match.groupCount == 2);
|
||||
if (filteredPackages.contains(match.group(2))) {
|
||||
final Match packageMatch = packageParser.firstMatch(match.group(2));
|
||||
if (packageMatch != null && packageMatch.group(1) == 'package') {
|
||||
skipped.add('package ${packageMatch.group(2)}'); // avoid "package package:foo"
|
||||
} else {
|
||||
skipped.add('package ${match.group(2)}');
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (filteredClasses.contains(match.group(1))) {
|
||||
skipped.add('class ${match.group(1)}');
|
||||
continue;
|
||||
}
|
||||
final StackFrame frameLine = StackFrame.fromStackTraceLine(line);
|
||||
if (filteredClasses.contains(frameLine.className)) {
|
||||
skipped.add('class ${frameLine.className}');
|
||||
} else if (filteredPackages.contains(frameLine.packageScheme + ':' + frameLine.package)) {
|
||||
skipped.add('package ${frameLine.packageScheme == 'dart' ? 'dart:' : ''}${frameLine.package}');
|
||||
} else {
|
||||
result.add(line);
|
||||
}
|
||||
result.add(line);
|
||||
}
|
||||
if (skipped.length == 1) {
|
||||
result.add('(elided one frame from ${skipped.single})');
|
||||
@ -794,9 +775,11 @@ class DiagnosticsStackTrace extends DiagnosticsBlock {
|
||||
}) : super(
|
||||
name: name,
|
||||
value: stack,
|
||||
properties: (stackFilter ?? FlutterError.defaultStackFilter)(stack.toString().trimRight().split('\n'))
|
||||
.map<DiagnosticsNode>(_createStackFrame)
|
||||
.toList(),
|
||||
properties: stack == null
|
||||
? <DiagnosticsNode>[]
|
||||
: (stackFilter ?? FlutterError.defaultStackFilter)(stack.toString().trimRight().split('\n'))
|
||||
.map<DiagnosticsNode>(_createStackFrame)
|
||||
.toList(),
|
||||
style: DiagnosticsTreeStyle.flat,
|
||||
showSeparator: showSeparator,
|
||||
allowTruncate: true,
|
||||
|
@ -1630,6 +1630,7 @@ abstract class DiagnosticsNode {
|
||||
return toStringDeep(parentConfiguration: parentConfiguration, minLevel: minLevel);
|
||||
|
||||
final String description = toDescription(parentConfiguration: parentConfiguration);
|
||||
assert(description != null);
|
||||
|
||||
if (name == null || name.isEmpty || !showName)
|
||||
return description;
|
||||
|
230
packages/flutter/lib/src/foundation/stack_frame.dart
Normal file
230
packages/flutter/lib/src/foundation/stack_frame.dart
Normal file
@ -0,0 +1,230 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:ui' show hashValues;
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
/// A object representation of a frame from a stack trace.
|
||||
///
|
||||
/// {@tool sample}
|
||||
///
|
||||
/// This example creates a traversable list of parsed [StackFrame] objects from
|
||||
/// the current [StackTrace].
|
||||
///
|
||||
/// ```dart
|
||||
/// final List<StackFrame> currentFrames = StackFrame.fromStackTrace(StackTrace.current);
|
||||
/// ```
|
||||
/// {@end-tool}
|
||||
@immutable
|
||||
class StackFrame {
|
||||
/// Creates a new StackFrame instance.
|
||||
///
|
||||
/// All parameters must not be null. The [className] may be the empty string
|
||||
/// if there is no class (e.g. for a top level library method).
|
||||
const StackFrame({
|
||||
@required this.number,
|
||||
@required this.column,
|
||||
@required this.line,
|
||||
@required this.packageScheme,
|
||||
@required this.package,
|
||||
@required this.packagePath,
|
||||
this.className = '',
|
||||
@required this.method,
|
||||
this.isConstructor = false,
|
||||
@required this.source,
|
||||
}) : assert(number != null),
|
||||
assert(column != null),
|
||||
assert(line != null),
|
||||
assert(method != null),
|
||||
assert(packageScheme != null),
|
||||
assert(package != null),
|
||||
assert(packagePath != null),
|
||||
assert(className != null),
|
||||
assert(isConstructor != null),
|
||||
assert(source != null);
|
||||
|
||||
/// A stack frame representing an asynchronous suspension.
|
||||
static const StackFrame asynchronousSuspension = StackFrame(
|
||||
number: -1,
|
||||
column: -1,
|
||||
line: -1,
|
||||
method: 'asynchronous suspension',
|
||||
packageScheme: '',
|
||||
package: '',
|
||||
packagePath: '',
|
||||
source: '<asynchronous suspension>',
|
||||
);
|
||||
|
||||
/// Parses a list of [StackFrame]s from a [StackTrace] object.
|
||||
///
|
||||
/// This is normally useful with [StackTrace.current].
|
||||
static List<StackFrame> fromStackTrace(StackTrace stack) {
|
||||
assert(stack != null);
|
||||
return fromStackString(stack.toString());
|
||||
}
|
||||
|
||||
/// Parses a list of [StackFrame]s from the [StackTrace.toString] method.
|
||||
static List<StackFrame> fromStackString(String stack) {
|
||||
assert(stack != null);
|
||||
return stack
|
||||
.trim()
|
||||
.split('\n')
|
||||
.map(fromStackTraceLine)
|
||||
.toList();
|
||||
}
|
||||
|
||||
static StackFrame _parseWebFrame(String line) {
|
||||
final bool hasPackage = line.startsWith('package');
|
||||
final RegExp parser = hasPackage
|
||||
? RegExp(r'^(package:.+) (\d+):(\d+)\s+(.+)$')
|
||||
: RegExp(r'^(.+) (\d+):(\d+)\s+(.+)$');
|
||||
final Match match = parser.firstMatch(line);
|
||||
assert(match != null, 'Expecgted $line to match $parser.');
|
||||
|
||||
String package = '<unknown>';
|
||||
String packageScheme = '<unknown>';
|
||||
String packagePath = '<unknown>';
|
||||
if (hasPackage) {
|
||||
packageScheme = 'package';
|
||||
final Uri packageUri = Uri.parse(match.group(1));
|
||||
package = packageUri.pathSegments[0];
|
||||
packagePath = packageUri.path.replaceFirst(packageUri.pathSegments[0] + '/', '');
|
||||
}
|
||||
|
||||
return StackFrame(
|
||||
number: -1,
|
||||
packageScheme: packageScheme,
|
||||
package: package,
|
||||
packagePath: packagePath,
|
||||
line: int.parse(match.group(2)),
|
||||
column: int.parse(match.group(3)),
|
||||
className: '<unknown>',
|
||||
method: match.group(4),
|
||||
source: line,
|
||||
);
|
||||
}
|
||||
|
||||
/// Parses a single [StackFrame] from a single line of a [StackTrace].
|
||||
static StackFrame fromStackTraceLine(String line) {
|
||||
assert(line != null);
|
||||
if (line == '<asynchronous suspension>') {
|
||||
return asynchronousSuspension;
|
||||
}
|
||||
|
||||
// Web frames.
|
||||
if (!line.startsWith('#')) {
|
||||
return _parseWebFrame(line);
|
||||
}
|
||||
|
||||
final RegExp parser = RegExp(r'^#(\d+) +(.+) \((.+?):?(\d+){0,1}:?(\d+){0,1}\)$');
|
||||
final Match match = parser.firstMatch(line);
|
||||
assert(match != null, 'Expected $line to match $parser.');
|
||||
|
||||
bool isConstructor = false;
|
||||
String className = '';
|
||||
String method = match.group(2).replaceAll('.<anonymous closure>', '');
|
||||
if (method.startsWith('new')) {
|
||||
className = method.split(' ')[1];
|
||||
method = '';
|
||||
if (className.contains('.')) {
|
||||
final List<String> parts = className.split('.');
|
||||
className = parts[0];
|
||||
method = parts[1];
|
||||
}
|
||||
isConstructor = true;
|
||||
} else if (method.contains('.')) {
|
||||
final List<String> parts = method.split('.');
|
||||
className = parts[0];
|
||||
method = parts[1];
|
||||
}
|
||||
|
||||
final Uri packageUri = Uri.parse(match.group(3));
|
||||
String package = '<unknown>';
|
||||
String packagePath = packageUri.path;
|
||||
if (packageUri.scheme == 'dart' || packageUri.scheme == 'package') {
|
||||
package = packageUri.pathSegments[0];
|
||||
packagePath = packageUri.path.replaceFirst(packageUri.pathSegments[0] + '/', '');
|
||||
}
|
||||
|
||||
return StackFrame(
|
||||
number: int.parse(match.group(1)),
|
||||
className: className,
|
||||
method: method,
|
||||
packageScheme: packageUri.scheme,
|
||||
package: package,
|
||||
packagePath: packagePath,
|
||||
line: match.group(4) == null ? -1 : int.parse(match.group(4)),
|
||||
column: match.group(5) == null ? -1 : int.parse(match.group(5)),
|
||||
isConstructor: isConstructor,
|
||||
source: line,
|
||||
);
|
||||
}
|
||||
|
||||
/// The original source of this stack frame.
|
||||
final String source;
|
||||
|
||||
/// The zero-indexed frame number.
|
||||
///
|
||||
/// This value may be -1 to indicate an unknown frame number.
|
||||
final int number;
|
||||
|
||||
/// The scheme of the package for this frame, e.g. "dart" for
|
||||
/// dart:core/errors_patch.dart or "package" for
|
||||
/// package:flutter/src/widgets/text.dart.
|
||||
///
|
||||
/// The path property refers to the source file.
|
||||
final String packageScheme;
|
||||
|
||||
/// The package for this frame, e.g. "core" for
|
||||
/// dart:core/errors_patch.dart or "flutter" for
|
||||
/// package:flutter/src/widgets/text.dart.
|
||||
final String package;
|
||||
|
||||
/// The path of the file for this frame, e.g. "errors_patch.dart" for
|
||||
/// dart:core/errors_patch.dart or "src/widgets/text.dart" for
|
||||
/// package:flutter/src/widgets/text.dart.
|
||||
final String packagePath;
|
||||
|
||||
/// The source line number.
|
||||
final int line;
|
||||
|
||||
/// The source column number.
|
||||
final int column;
|
||||
|
||||
/// The class name, if any, for this frame.
|
||||
///
|
||||
/// This may be null for top level methods in a library or anonymous closure
|
||||
/// methods.
|
||||
final String className;
|
||||
|
||||
/// The method name for this frame.
|
||||
///
|
||||
/// This will be an empty string if the stack frame is from the default
|
||||
/// constructor.
|
||||
final String method;
|
||||
|
||||
/// Whether or not this was thrown from a constructor.
|
||||
final bool isConstructor;
|
||||
|
||||
@override
|
||||
int get hashCode => hashValues(number, package, line, column, className, method, source);
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (runtimeType != other.runtimeType)
|
||||
return false;
|
||||
return other is StackFrame &&
|
||||
number == other.number &&
|
||||
package == other.package &&
|
||||
line == other.line &&
|
||||
column == other.column &&
|
||||
className == other.className &&
|
||||
method == other.method &&
|
||||
source == other.source;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() => '$runtimeType(#$number, $packageScheme:$package/$packagePath:$line:$column, className: $className, method: $method)';
|
||||
}
|
@ -352,4 +352,80 @@ void main() {
|
||||
expect(summary.value, equals(<String>['Invalid argument(s) (myArgument): Must not be null']));
|
||||
}
|
||||
});
|
||||
|
||||
test('Identifies user fault', () {
|
||||
// User fault because they called `new Text(null)` from their own code.
|
||||
final StackTrace stack = StackTrace.fromString('''#0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:42:39)
|
||||
#1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:38:5)
|
||||
#2 new Text (package:flutter/src/widgets/text.dart:287:10)
|
||||
#3 _MyHomePageState.build (package:hello_flutter/main.dart:72:16)
|
||||
#4 StatefulElement.build (package:flutter/src/widgets/framework.dart:4414:27)
|
||||
#5 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4303:15)
|
||||
#6 Element.rebuild (package:flutter/src/widgets/framework.dart:4027:5)
|
||||
#7 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4286:5)
|
||||
#8 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4461:11)
|
||||
#9 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4281:5)
|
||||
#10 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3276:14)
|
||||
#11 Element.updateChild (package:flutter/src/widgets/framework.dart:3070:12)
|
||||
#12 SingleChildRenderObjectElement.mount (package:flutter/blah.dart:999:9)''');
|
||||
|
||||
final FlutterErrorDetails details = FlutterErrorDetails(
|
||||
exception: AssertionError('Test assertion'),
|
||||
stack: stack,
|
||||
);
|
||||
|
||||
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
|
||||
details.debugFillProperties(builder);
|
||||
|
||||
expect(builder.properties.length, 4);
|
||||
expect(builder.properties[0].toString(), 'The following assertion was thrown:');
|
||||
expect(builder.properties[1].toString(), 'Assertion failed');
|
||||
expect(builder.properties[2] is ErrorSpacer, true);
|
||||
final DiagnosticsStackTrace trace = builder.properties[3] as DiagnosticsStackTrace;
|
||||
expect(trace, isNotNull);
|
||||
expect(trace.value, stack);
|
||||
});
|
||||
|
||||
test('Identifies our fault', () {
|
||||
// Our fault because we should either have an assertion in `text_helper.dart`
|
||||
// or we should make sure not to pass bad values into new Text.
|
||||
final StackTrace stack = StackTrace.fromString('''#0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:42:39)
|
||||
#1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:38:5)
|
||||
#2 new Text (package:flutter/src/widgets/text.dart:287:10)
|
||||
#3 new SomeWidgetUsingText (package:flutter/src/widgets/text_helper.dart:287:10)
|
||||
#4 _MyHomePageState.build (package:hello_flutter/main.dart:72:16)
|
||||
#5 StatefulElement.build (package:flutter/src/widgets/framework.dart:4414:27)
|
||||
#6 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4303:15)
|
||||
#7 Element.rebuild (package:flutter/src/widgets/framework.dart:4027:5)
|
||||
#8 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4286:5)
|
||||
#9 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4461:11)
|
||||
#10 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4281:5)
|
||||
#11 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3276:14)
|
||||
#12 Element.updateChild (package:flutter/src/widgets/framework.dart:3070:12)
|
||||
#13 SingleChildRenderObjectElement.mount (package:flutter/blah.dart:999:9)''');
|
||||
|
||||
final FlutterErrorDetails details = FlutterErrorDetails(
|
||||
exception: AssertionError('Test assertion'),
|
||||
stack: stack,
|
||||
);
|
||||
|
||||
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
|
||||
details.debugFillProperties(builder);
|
||||
expect(builder.properties.length, 6);
|
||||
expect(builder.properties[0].toString(), 'The following assertion was thrown:');
|
||||
expect(builder.properties[1].toString(), 'Assertion failed');
|
||||
expect(builder.properties[2] is ErrorSpacer, true);
|
||||
expect(
|
||||
builder.properties[3].toString(),
|
||||
'Either the assertion indicates an error in the framework itself, or we should '
|
||||
'provide substantially more information in this error message to help you determine '
|
||||
'and fix the underlying cause.\n'
|
||||
'In either case, please report this assertion by filing a bug on GitHub:\n'
|
||||
' https://github.com/flutter/flutter/issues/new?template=BUG.md',
|
||||
);
|
||||
expect(builder.properties[4] is ErrorSpacer, true);
|
||||
final DiagnosticsStackTrace trace = builder.properties[5] as DiagnosticsStackTrace;
|
||||
expect(trace, isNotNull);
|
||||
expect(trace.value, stack);
|
||||
});
|
||||
}
|
||||
|
@ -1849,18 +1849,18 @@ void main() {
|
||||
|
||||
test('Stack trace test', () {
|
||||
final StackTrace stack = StackTrace.fromString(
|
||||
'#0 someMethod() file:///diagnostics_test.dart:42:19\n'
|
||||
'#1 someMethod2() file:///diagnostics_test.dart:12:3\n'
|
||||
'#2 someMethod3() file:///foo.dart:4:1\n'
|
||||
'#0 someMethod (file:///diagnostics_test.dart:42:19)\n'
|
||||
'#1 someMethod2 (file:///diagnostics_test.dart:12:3)\n'
|
||||
'#2 someMethod3 (file:///foo.dart:4:1)\n'
|
||||
);
|
||||
|
||||
expect(
|
||||
DiagnosticsStackTrace('Stack trace', stack).toStringDeep(),
|
||||
equalsIgnoringHashCodes(
|
||||
'Stack trace:\n'
|
||||
'#0 someMethod() file:///diagnostics_test.dart:42:19\n'
|
||||
'#1 someMethod2() file:///diagnostics_test.dart:12:3\n'
|
||||
'#2 someMethod3() file:///foo.dart:4:1\n'
|
||||
'#0 someMethod (file:///diagnostics_test.dart:42:19)\n'
|
||||
'#1 someMethod2 (file:///diagnostics_test.dart:12:3)\n'
|
||||
'#2 someMethod3 (file:///foo.dart:4:1)\n'
|
||||
),
|
||||
);
|
||||
|
||||
@ -1868,9 +1868,9 @@ void main() {
|
||||
DiagnosticsStackTrace('-- callback 2 --', stack, showSeparator: false).toStringDeep(),
|
||||
equalsIgnoringHashCodes(
|
||||
'-- callback 2 --\n'
|
||||
'#0 someMethod() file:///diagnostics_test.dart:42:19\n'
|
||||
'#1 someMethod2() file:///diagnostics_test.dart:12:3\n'
|
||||
'#2 someMethod3() file:///foo.dart:4:1\n'
|
||||
'#0 someMethod (file:///diagnostics_test.dart:42:19)\n'
|
||||
'#1 someMethod2 (file:///diagnostics_test.dart:12:3)\n'
|
||||
'#2 someMethod3 (file:///foo.dart:4:1)\n'
|
||||
),
|
||||
);
|
||||
});
|
||||
|
@ -45,13 +45,18 @@ Future<void> main() async {
|
||||
|
||||
final StackTrace sampleStack = await getSampleStack();
|
||||
|
||||
test('Error reporting - pretest', () async {
|
||||
setUp(() async {
|
||||
expect(debugPrint, equals(debugPrintThrottled));
|
||||
debugPrint = (String message, { int wrapWidth }) {
|
||||
console.add(message);
|
||||
};
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
expect(console, isEmpty);
|
||||
debugPrint = debugPrintThrottled;
|
||||
});
|
||||
|
||||
test('Error reporting - assert with message', () async {
|
||||
expect(console, isEmpty);
|
||||
FlutterError.dumpErrorToConsole(FlutterErrorDetails(
|
||||
@ -71,11 +76,6 @@ Future<void> main() async {
|
||||
'\'[^\']+flutter/test/foundation/error_reporting_test\\.dart\':\n'
|
||||
'Failed assertion: line [0-9]+ pos [0-9]+: \'false\'\n'
|
||||
'\n'
|
||||
'Either the assertion indicates an error in the framework itself, or we should provide substantially\n'
|
||||
'more information in this error message to help you determine and fix the underlying cause\\.\n'
|
||||
'In either case, please report this assertion by filing a bug on GitHub:\n'
|
||||
' https://github\\.com/flutter/flutter/issues/new\\?template=BUG\\.md\n'
|
||||
'\n'
|
||||
'When the exception was thrown, this was the stack:\n'
|
||||
'#0 getSampleStack\\.<anonymous closure> \\([^)]+flutter/test/foundation/error_reporting_test\\.dart:[0-9]+:[0-9]+\\)\n'
|
||||
'#2 getSampleStack \\([^)]+flutter/test/foundation/error_reporting_test\\.dart:[0-9]+:[0-9]+\\)\n'
|
||||
@ -111,11 +111,6 @@ Future<void> main() async {
|
||||
'word word word word word word word word word word word word word word word word word word word word\n'
|
||||
'\'[^\']+flutter/test/foundation/error_reporting_test\\.dart\':\n'
|
||||
'Failed assertion: line [0-9]+ pos [0-9]+: \'false\'\n'
|
||||
'\n'
|
||||
'Either the assertion indicates an error in the framework itself, or we should provide substantially\n'
|
||||
'more information in this error message to help you determine and fix the underlying cause\\.\n'
|
||||
'In either case, please report this assertion by filing a bug on GitHub:\n'
|
||||
' https://github\\.com/flutter/flutter/issues/new\\?template=BUG\\.md\n'
|
||||
'════════════════════════════════════════════════════════════════════════════════════════════════════\$',
|
||||
));
|
||||
console.clear();
|
||||
@ -153,11 +148,6 @@ Future<void> main() async {
|
||||
'\'[^\']+flutter/test/foundation/error_reporting_test\\.dart\':[\n ]'
|
||||
'Failed[\n ]assertion:[\n ]line[\n ][0-9]+[\n ]pos[\n ][0-9]+:[\n ]\'false\':[\n ]is[\n ]not[\n ]true\\.\n'
|
||||
'\n'
|
||||
'Either the assertion indicates an error in the framework itself, or we should provide substantially\n'
|
||||
'more information in this error message to help you determine and fix the underlying cause\\.\n'
|
||||
'In either case, please report this assertion by filing a bug on GitHub:\n'
|
||||
' https://github\\.com/flutter/flutter/issues/new\\?template=BUG\\.md\n'
|
||||
'\n'
|
||||
'When the exception was thrown, this was the stack:\n'
|
||||
'#0 getSampleStack\\.<anonymous closure> \\([^)]+flutter/test/foundation/error_reporting_test\\.dart:[0-9]+:[0-9]+\\)\n'
|
||||
'#2 getSampleStack \\([^)]+flutter/test/foundation/error_reporting_test\\.dart:[0-9]+:[0-9]+\\)\n'
|
||||
@ -219,9 +209,4 @@ Future<void> main() async {
|
||||
console.clear();
|
||||
FlutterError.resetErrorCount();
|
||||
});
|
||||
|
||||
test('Error reporting - posttest', () async {
|
||||
expect(console, isEmpty);
|
||||
debugPrint = debugPrintThrottled;
|
||||
});
|
||||
}
|
||||
|
225
packages/flutter/test/foundation/stack_frame_test.dart
Normal file
225
packages/flutter/test/foundation/stack_frame_test.dart
Normal file
@ -0,0 +1,225 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import '../flutter_test_alternative.dart';
|
||||
|
||||
void main() {
|
||||
test('Parses line', () {
|
||||
expect(
|
||||
StackFrame.fromStackTraceLine(stackString.split('\n')[0]),
|
||||
stackFrames[0],
|
||||
);
|
||||
});
|
||||
|
||||
test('Parses string', () {
|
||||
expect(
|
||||
StackFrame.fromStackString(stackString),
|
||||
stackFrames,
|
||||
);
|
||||
});
|
||||
|
||||
test('Parses StackTrace', () {
|
||||
expect(
|
||||
StackFrame.fromStackTrace(StackTrace.fromString(stackString)),
|
||||
stackFrames,
|
||||
);
|
||||
});
|
||||
|
||||
test('Parses complex stack', () {
|
||||
expect(
|
||||
StackFrame.fromStackString(asyncStackString),
|
||||
asyncStackFrames,
|
||||
);
|
||||
});
|
||||
|
||||
test('Parses stack without cols', () {
|
||||
expect(
|
||||
StackFrame.fromStackString(stackFrameNoCols),
|
||||
stackFrameNoColsFrames,
|
||||
);
|
||||
});
|
||||
|
||||
test('Parses web stack', () {
|
||||
expect(
|
||||
StackFrame.fromStackString(webStackTrace),
|
||||
webStackTraceFrames,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
const String stackString = '''#0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:42:39)
|
||||
#1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:38:5)
|
||||
#2 new Text (package:flutter/src/widgets/text.dart:287:10)
|
||||
#3 _MyHomePageState.build (package:hello_flutter/main.dart:72:16)
|
||||
#4 StatefulElement.build (package:flutter/src/widgets/framework.dart:4414:27)
|
||||
#5 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4303:15)
|
||||
#6 Element.rebuild (package:flutter/src/widgets/framework.dart:4027:5)
|
||||
#7 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4286:5)
|
||||
#8 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4461:11)
|
||||
#9 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4281:5)
|
||||
#10 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3276:14)
|
||||
#11 Element.updateChild (package:flutter/src/widgets/framework.dart)
|
||||
#12 SingleChildRenderObjectElement.mount (package:flutter/blah.dart:999:9)
|
||||
#13 main (package:hello_flutter/main.dart:10:4)''';
|
||||
|
||||
const List<StackFrame> stackFrames = <StackFrame>[
|
||||
StackFrame(number: 0, className: '_AssertionError', method: '_doThrowNew', packageScheme: 'dart', package: 'core-patch', packagePath: 'errors_patch.dart', line: 42, column: 39, source: '#0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:42:39)'),
|
||||
StackFrame(number: 1, className: '_AssertionError', method: '_throwNew', packageScheme: 'dart', package: 'core-patch', packagePath: 'errors_patch.dart', line: 38, column: 5, source: '#1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:38:5)'),
|
||||
StackFrame(number: 2, className: 'Text', method: '', packageScheme: 'package', package: 'flutter', packagePath: 'src/widgets/text.dart', line: 287, column: 10, isConstructor: true, source: '#2 new Text (package:flutter/src/widgets/text.dart:287:10)'),
|
||||
StackFrame(number: 3, className: '_MyHomePageState', method: 'build', packageScheme: 'package', package: 'hello_flutter', packagePath: 'main.dart', line: 72, column: 16, source: '#3 _MyHomePageState.build (package:hello_flutter/main.dart:72:16)'),
|
||||
StackFrame(number: 4, className: 'StatefulElement', method: 'build', packageScheme: 'package', package: 'flutter', packagePath: 'src/widgets/framework.dart', line: 4414, column: 27, source: '#4 StatefulElement.build (package:flutter/src/widgets/framework.dart:4414:27)'),
|
||||
StackFrame(number: 5, className: 'ComponentElement', method: 'performRebuild', packageScheme: 'package', package: 'flutter', packagePath: 'src/widgets/framework.dart', line: 4303, column: 15, source: '#5 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4303:15)'),
|
||||
StackFrame(number: 6, className: 'Element', method: 'rebuild', packageScheme: 'package', package: 'flutter', packagePath: 'src/widgets/framework.dart', line: 4027, column: 5, source: '#6 Element.rebuild (package:flutter/src/widgets/framework.dart:4027:5)'),
|
||||
StackFrame(number: 7, className: 'ComponentElement', method: '_firstBuild', packageScheme: 'package', package: 'flutter', packagePath: 'src/widgets/framework.dart', line: 4286, column: 5, source: '#7 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4286:5)'),
|
||||
StackFrame(number: 8, className: 'StatefulElement', method: '_firstBuild', packageScheme: 'package', package: 'flutter', packagePath: 'src/widgets/framework.dart', line: 4461, column: 11, source: '#8 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4461:11)'),
|
||||
StackFrame(number: 9, className: 'ComponentElement', method: 'mount', packageScheme: 'package', package: 'flutter', packagePath: 'src/widgets/framework.dart', line: 4281, column: 5, source: '#9 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4281:5)'),
|
||||
StackFrame(number: 10, className: 'Element', method: 'inflateWidget', packageScheme: 'package', package: 'flutter', packagePath: 'src/widgets/framework.dart', line: 3276, column: 14, source: '#10 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3276:14)'),
|
||||
StackFrame(number: 11, className: 'Element', method: 'updateChild', packageScheme: 'package', package: 'flutter', packagePath: 'src/widgets/framework.dart', line: -1, column: -1, source: '#11 Element.updateChild (package:flutter/src/widgets/framework.dart)'),
|
||||
StackFrame(number: 12, className: 'SingleChildRenderObjectElement', method: 'mount', packageScheme: 'package', package: 'flutter', packagePath: 'blah.dart', line: 999, column: 9, source: '#12 SingleChildRenderObjectElement.mount (package:flutter/blah.dart:999:9)'),
|
||||
StackFrame(number: 13, className: '', method: 'main', packageScheme: 'package', package: 'hello_flutter', packagePath: 'main.dart', line: 10, column: 4, source: '#13 main (package:hello_flutter/main.dart:10:4)'),
|
||||
];
|
||||
|
||||
|
||||
const String asyncStackString = '''#0 getSampleStack.<anonymous closure> (file:///path/to/flutter/packages/flutter/test/foundation/error_reporting_test.dart:40:57)
|
||||
#1 new Future.sync (dart:async/future.dart:224:31)
|
||||
#2 getSampleStack (file:///path/to/flutter/packages/flutter/test/foundation/error_reporting_test.dart:40:10)
|
||||
#3 main (file:///path/to/flutter/packages/flutter/test/foundation/error_reporting_test.dart:46:40)
|
||||
#4 main (package:flutter_goldens/flutter_goldens.dart:43:17)
|
||||
<asynchronous suspension>
|
||||
#5 main.<anonymous closure>.<anonymous closure> (file:///temp/path.whatever/listener.dart:47:18)
|
||||
#6 _rootRun (dart:async/zone.dart:1126:13)
|
||||
#7 _CustomZone.run (dart:async/zone.dart:1023:19)
|
||||
#8 _runZoned (dart:async/zone.dart:1518:10)
|
||||
#9 runZoned (dart:async/zone.dart:1465:12)
|
||||
#10 Declarer.declare (package:test_api/src/backend/declarer.dart:130:22)
|
||||
#11 RemoteListener.start.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:test_api/src/remote_listener.dart:124:26)
|
||||
<asynchronous suspension>
|
||||
#12 _rootRun (dart:async/zone.dart:1126:13)
|
||||
#13 _CustomZone.run (dart:async/zone.dart:1023:19)
|
||||
#14 _runZoned (dart:async/zone.dart:1518:10)
|
||||
#15 runZoned (dart:async/zone.dart:1502:12)
|
||||
#16 RemoteListener.start.<anonymous closure>.<anonymous closure> (package:test_api/src/remote_listener.dart:70:9)
|
||||
#17 _rootRun (dart:async/zone.dart:1126:13)
|
||||
#18 _CustomZone.run (dart:async/zone.dart:1023:19)
|
||||
#19 _runZoned (dart:async/zone.dart:1518:10)
|
||||
#20 runZoned (dart:async/zone.dart:1465:12)
|
||||
#21 StackTraceFormatter.asCurrent (package:test_api/src/backend/stack_trace_formatter.dart:41:31)
|
||||
#22 RemoteListener.start.<anonymous closure> (package:test_api/src/remote_listener.dart:69:29)
|
||||
#23 _rootRun (dart:async/zone.dart:1126:13)
|
||||
#24 _CustomZone.run (dart:async/zone.dart:1023:19)
|
||||
#25 _runZoned (dart:async/zone.dart:1518:10)
|
||||
#26 runZoned (dart:async/zone.dart:1465:12)
|
||||
#27 SuiteChannelManager.asCurrent (package:test_api/src/suite_channel_manager.dart:34:31)
|
||||
#28 RemoteListener.start (package:test_api/src/remote_listener.dart:68:27)
|
||||
#29 serializeSuite (file:///temp/path.whatever/listener.dart:17:25)
|
||||
#30 main (file:///temp/path.whatever/listener.dart:43:36)
|
||||
#31 _runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:239:25)
|
||||
#32 _rootRun (dart:async/zone.dart:1126:13)
|
||||
#33 _CustomZone.run (dart:async/zone.dart:1023:19)
|
||||
#34 _runZoned (dart:async/zone.dart:1518:10)
|
||||
#35 runZoned (dart:async/zone.dart:1502:12)
|
||||
#36 _runMainZoned.<anonymous closure> (dart:ui/hooks.dart:231:5)
|
||||
#37 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:307:19)
|
||||
#38 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)''';
|
||||
|
||||
const List<StackFrame> asyncStackFrames = <StackFrame>[
|
||||
StackFrame(number: 0, className: '', method: 'getSampleStack', packageScheme: 'file', package: '<unknown>', packagePath: '/path/to/flutter/packages/flutter/test/foundation/error_reporting_test.dart', line: 40, column: 57, source: '#0 getSampleStack.<anonymous closure> (file:///path/to/flutter/packages/flutter/test/foundation/error_reporting_test.dart:40:57)'),
|
||||
StackFrame(number: 1, className: 'Future', method: 'sync', packageScheme: 'dart', package: 'async', packagePath: 'future.dart', line: 224, column: 31, isConstructor: true, source: '#1 new Future.sync (dart:async/future.dart:224:31)'),
|
||||
StackFrame(number: 2, className: '', method: 'getSampleStack', packageScheme: 'file', package: '<unknown>', packagePath: '/path/to/flutter/packages/flutter/test/foundation/error_reporting_test.dart', line: 40, column: 10, source: '#2 getSampleStack (file:///path/to/flutter/packages/flutter/test/foundation/error_reporting_test.dart:40:10)'),
|
||||
StackFrame(number: 3, className: '', method: 'main', packageScheme: 'file', package: '<unknown>', packagePath: '/path/to/flutter/packages/flutter/foundation/error_reporting_test.dart', line: 46, column: 40, source: '#3 main (file:///path/to/flutter/packages/flutter/test/foundation/error_reporting_test.dart:46:40)'),
|
||||
StackFrame(number: 4, className: '', method: 'main', packageScheme: 'package', package: 'flutter_goldens', packagePath: 'flutter_goldens.dart', line: 43, column: 17, source: '#4 main (package:flutter_goldens/flutter_goldens.dart:43:17)'),
|
||||
StackFrame.asynchronousSuspension,
|
||||
StackFrame(number: 5, className: '', method: 'main', packageScheme: 'file', package: '<unknown>', packagePath: '/temp/path.whatever/listener.dart', line: 47, column: 18, source: '#5 main.<anonymous closure>.<anonymous closure> (file:///temp/path.whatever/listener.dart:47:18)'),
|
||||
StackFrame(number: 6, className: '', method: '_rootRun', packageScheme: 'dart', package: 'async', packagePath: 'zone.dart', line: 1126, column: 13, source: '#6 _rootRun (dart:async/zone.dart:1126:13)'),
|
||||
StackFrame(number: 7, className: '_CustomZone', method: 'run', packageScheme: 'dart', package: 'async', packagePath: 'zone.dart', line: 1023, column: 19, source: '#7 _CustomZone.run (dart:async/zone.dart:1023:19)'),
|
||||
StackFrame(number: 8, className: '', method: '_runZoned', packageScheme: 'dart', package: 'async', packagePath: 'zone.dart', line: 1518, column: 10, source: '#8 _runZoned (dart:async/zone.dart:1518:10)'),
|
||||
StackFrame(number: 9, className: '', method: 'runZoned', packageScheme: 'dart', package: 'async', packagePath: 'zone.dart', line: 1465, column: 12, source: '#9 runZoned (dart:async/zone.dart:1465:12)'),
|
||||
StackFrame(number: 10, className: 'Declarer', method: 'declare', packageScheme: 'package', package: 'test_api', packagePath: 'src/backend/declarer.dart', line: 130, column: 22, source: '#10 Declarer.declare (package:test_api/src/backend/declarer.dart:130:22)'),
|
||||
StackFrame(number: 11, className: 'RemoteListener', method: 'start', packageScheme: 'package', package: 'test_api', packagePath: 'src/remote_listener.dart', line: 124, column: 26, source: '#11 RemoteListener.start.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:test_api/src/remote_listener.dart:124:26)'),
|
||||
StackFrame.asynchronousSuspension,
|
||||
StackFrame(number: 12, className: '', method: '_rootRun', packageScheme: 'dart', package: 'async', packagePath: 'zone.dart', line: 1126, column: 13, source: '#12 _rootRun (dart:async/zone.dart:1126:13)'),
|
||||
StackFrame(number: 13, className: '_CustomZone', method: 'run' , packageScheme: 'dart', package: 'async', packagePath: 'zone.dart', line: 1023, column: 19, source: '#13 _CustomZone.run (dart:async/zone.dart:1023:19)'),
|
||||
StackFrame(number: 14, className: '', method: '_runZoned', packageScheme: 'dart', package: 'async', packagePath: 'zone.dart', line: 1518, column: 10, source: '#14 _runZoned (dart:async/zone.dart:1518:10)'),
|
||||
StackFrame(number: 15, className: '', method: 'runZoned', packageScheme: 'dart', package: 'async', packagePath: 'zone.dart', line: 1502, column: 12, source: '#15 runZoned (dart:async/zone.dart:1502:12)'),
|
||||
StackFrame(number: 16, className: 'RemoteListener', method: 'start', packageScheme: 'package', package: 'test_api', packagePath: 'src/remote_listener.dart', line: 70, column: 9, source: '#16 RemoteListener.start.<anonymous closure>.<anonymous closure> (package:test_api/src/remote_listener.dart:70:9)'),
|
||||
StackFrame(number: 17, className: '', method: '_rootRun', packageScheme: 'dart', package: 'async', packagePath: 'zone.dart', line: 1126, column: 13, source: '#17 _rootRun (dart:async/zone.dart:1126:13)'),
|
||||
StackFrame(number: 18, className: '_CustomZone', method: 'run', packageScheme: 'dart', package: 'async', packagePath: 'zone.dart', line: 1023, column: 19, source: '#18 _CustomZone.run (dart:async/zone.dart:1023:19)'),
|
||||
StackFrame(number: 19, className: '', method: '_runZoned', packageScheme: 'dart', package: 'async', packagePath: 'zone.dart', line: 1518, column: 10, source: '#19 _runZoned (dart:async/zone.dart:1518:10)'),
|
||||
StackFrame(number: 20, className: '', method: 'runZoned', packageScheme: 'dart', package: 'async', packagePath: 'zone.dart', line: 1465, column: 12, source: '#20 runZoned (dart:async/zone.dart:1465:12)'),
|
||||
StackFrame(number: 21, className: 'StackTraceFormatter', method: 'asCurrent', packageScheme: 'package', package: 'test_api', packagePath: 'src/backend/stack_trace_formatter.dart', line: 41, column: 31, source: '#21 StackTraceFormatter.asCurrent (package:test_api/src/backend/stack_trace_formatter.dart:41:31)'),
|
||||
StackFrame(number: 22, className: 'RemoteListener', method: 'start', packageScheme: 'package', package: 'test_api', packagePath: 'src/remote_listener.dart', line: 69, column: 29, source: '#22 RemoteListener.start.<anonymous closure> (package:test_api/src/remote_listener.dart:69:29)'),
|
||||
StackFrame(number: 23, className: '', method: '_rootRun', packageScheme: 'dart', package: 'async', packagePath: 'zone.dart', line: 1126, column: 13, source: '#23 _rootRun (dart:async/zone.dart:1126:13)'),
|
||||
StackFrame(number: 24, className: '_CustomZone', method: 'run', packageScheme: 'dart', package: 'async', packagePath: 'zone.dart', line: 1023, column: 19, source: '#24 _CustomZone.run (dart:async/zone.dart:1023:19)'),
|
||||
StackFrame(number: 25, className: '', method: '_runZoned', packageScheme: 'dart', package: 'async', packagePath: 'zone.dart', line: 1518, column: 10, source: '#25 _runZoned (dart:async/zone.dart:1518:10)'),
|
||||
StackFrame(number: 26, className: '', method: 'runZoned', packageScheme: 'dart', package: 'async', packagePath: 'zone.dart', line: 1465, column: 12, source: '#26 runZoned (dart:async/zone.dart:1465:12)'),
|
||||
StackFrame(number: 27, className: 'SuiteChannelManager', method: 'asCurrent', packageScheme: 'package', package: 'test_api', packagePath: 'src/suite_channel_manager.dart', line: 34, column: 31, source: '#27 SuiteChannelManager.asCurrent (package:test_api/src/suite_channel_manager.dart:34:31)'),
|
||||
StackFrame(number: 28, className: 'RemoteListener', method: 'start', packageScheme: 'package', package: 'test_api', packagePath: 'src/remote_listener.dart', line: 68, column: 27, source: '#28 RemoteListener.start (package:test_api/src/remote_listener.dart:68:27)'),
|
||||
StackFrame(number: 29, className: '', method: 'serializeSuite', packageScheme: 'file', package: '<unknown>', packagePath: '/temp/path.whatever/listener.dart', line: 17, column: 25, source: '#29 serializeSuite (file:///temp/path.whatever/listener.dart:17:25)'),
|
||||
StackFrame(number: 30, className: '', method: 'main', packageScheme: 'file', package: '<unknown>', packagePath: '/temp/path.whatever/listener.dart', line: 43, column: 36, source: '#30 main (file:///temp/path.whatever/listener.dart:43:36)'),
|
||||
StackFrame(number: 31, className: '', method: '_runMainZoned', packageScheme: 'dart', package: 'ui', packagePath: 'hooks.dart', line:239, column: 25, source: '#31 _runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:239:25)'),
|
||||
StackFrame(number: 32, className: '', method: '_rootRun', packageScheme: 'dart', package: 'async', packagePath: 'zone.dart', line: 1126, column: 13, source: '#32 _rootRun (dart:async/zone.dart:1126:13)'),
|
||||
StackFrame(number: 33, className: '_CustomZone', method: 'run' , packageScheme: 'dart', package: 'async', packagePath: 'zone.dart', line: 1023, column: 19, source: '#33 _CustomZone.run (dart:async/zone.dart:1023:19)'),
|
||||
StackFrame(number: 34, className: '', method: '_runZoned', packageScheme: 'dart', package: 'async', packagePath: 'zone.dart', line: 1518, column: 10, source: '#34 _runZoned (dart:async/zone.dart:1518:10)'),
|
||||
StackFrame(number: 35, className: '', method: 'runZoned', packageScheme: 'dart', package: 'async', packagePath: 'zone.dart', line: 1502, column: 12, source: '#35 runZoned (dart:async/zone.dart:1502:12)'),
|
||||
StackFrame(number: 36, className: '', method: '_runMainZoned', packageScheme: 'dart', package: 'ui', packagePath: 'hooks.dart', line: 231, column: 5, source: '#36 _runMainZoned.<anonymous closure> (dart:ui/hooks.dart:231:5)'),
|
||||
StackFrame(number: 37, className: '', method: '_startIsolate', packageScheme: 'dart', package: 'isolate-patch', packagePath: 'isolate_patch.dart', line: 307, column: 19, source: '#37 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:307:19)'),
|
||||
StackFrame(number: 38, className: '_RawReceivePortImpl', method: '_handleMessage', packageScheme: 'dart', package: 'isolate-patch', packagePath: 'isolate_patch.dart', line: 174, column: 12, source: '#38 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)'),
|
||||
];
|
||||
|
||||
const String stackFrameNoCols = '''#0 blah (package:assertions/main.dart:4)
|
||||
#1 main (package:assertions/main.dart:8)
|
||||
#2 _runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:239)
|
||||
#3 _rootRun (dart:async/zone.dart:1126)
|
||||
#4 _CustomZone.run (dart:async/zone.dart:1023)
|
||||
#5 _runZoned (dart:async/zone.dart:1518)
|
||||
#6 runZoned (dart:async/zone.dart:1502)
|
||||
#7 _runMainZoned.<anonymous closure> (dart:ui/hooks.dart:231)
|
||||
#8 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:307)
|
||||
#9 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174)''';
|
||||
|
||||
const List<StackFrame> stackFrameNoColsFrames = <StackFrame>[
|
||||
StackFrame(number: 0, className: '', method: 'blah', packageScheme: 'package', package: 'assertions', packagePath: 'main.dart', line: 4, column: -1, source: '#0 blah (package:assertions/main.dart:4)'),
|
||||
StackFrame(number: 1, className: '', method: 'main', packageScheme: 'package', package: 'assertions', packagePath: 'main.dart', line: 8, column: -1, source: '#1 main (package:assertions/main.dart:8)'),
|
||||
StackFrame(number: 2, className: '', method: '_runMainZoned', packageScheme: 'dart', package: 'ui', packagePath: 'hooks.dart', line: 239, column: -1, source: '#2 _runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:239)'),
|
||||
StackFrame(number: 3, className: '', method: '_rootRun', packageScheme: 'dart', package: 'async', packagePath: 'zone.dart', line: 1126, column: -1, source: '#3 _rootRun (dart:async/zone.dart:1126)'),
|
||||
StackFrame(number: 4, className: '_CustomZone', method: 'run', packageScheme: 'dart', package: 'async', packagePath: 'zone.dart', line: 1023, column: -1, source: '#4 _CustomZone.run (dart:async/zone.dart:1023)'),
|
||||
StackFrame(number: 5, className: '', method: '_runZoned', packageScheme: 'dart', package: 'async', packagePath: 'zone.dart', line: 1518, column: -1, source: '#5 _runZoned (dart:async/zone.dart:1518)'),
|
||||
StackFrame(number: 6, className: '', method: 'runZoned', packageScheme: 'dart', package: 'async', packagePath: 'zone.dart', line: 1502, column: -1, source: '#6 runZoned (dart:async/zone.dart:1502)'),
|
||||
StackFrame(number: 7, className: '', method: '_runMainZoned', packageScheme: 'dart', package: 'ui', packagePath: 'hooks.dart', line: 231, column: -1, source: '#7 _runMainZoned.<anonymous closure> (dart:ui/hooks.dart:231)'),
|
||||
StackFrame(number: 8, className: '', method: '_startIsolate', packageScheme: 'dart', package: 'isolate-patch', packagePath: 'isolate-patch.dart', line: 307, column: -1, source: '#8 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:307)'),
|
||||
StackFrame(number: 9, className: '_RawReceivePortImpl', method: '_handleMessage', packageScheme: 'dart', package: 'isolate-patch', packagePath: 'isolate-patch.dart', line: 174, column: -1, source: '#9 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174)'),
|
||||
];
|
||||
|
||||
const String webStackTrace = r'''package:dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 196:49 throw_
|
||||
package:assertions/main.dart 4:3 blah
|
||||
package:assertions/main.dart 8:5 main$
|
||||
package:assertions/main_web_entrypoint.dart 9:3 main$
|
||||
package:dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 47:50 onValue
|
||||
package:dart-sdk/lib/async/zone.dart 1381:54 runUnary
|
||||
object_test.dart 210:5 performLayout
|
||||
package:dart-sdk/lib/async/future_impl.dart 140:18 handleValue
|
||||
package:dart-sdk/lib/async/future_impl.dart 682:44 handleValueCallback
|
||||
package:dart-sdk/lib/async/future_impl.dart 711:32 _propagateToListeners
|
||||
package:dart-sdk/lib/async/future_impl.dart 391:9 callback
|
||||
package:dart-sdk/lib/async/schedule_microtask.dart 43:11 _microtaskLoop
|
||||
package:dart-sdk/lib/async/schedule_microtask.dart 52:5 _startMicrotaskLoop
|
||||
package:dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 168:15 <fn>''';
|
||||
|
||||
const List<StackFrame> webStackTraceFrames = <StackFrame>[
|
||||
StackFrame(number: -1, className: '<unknown>', method: 'throw_', packageScheme: 'package', package: 'dart-sdk', packagePath: 'lib/_intenral/js_dev_runtime/private/ddc_runtime/errors.dart', line: 196, column: 49, source: 'package:dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 196:49 throw_'),
|
||||
StackFrame(number: -1, className: '<unknown>', method: 'blah', packageScheme: 'package', package: 'assertions', packagePath: 'main.dart', line: 4, column: 3, source: 'package:assertions/main.dart 4:3 blah'),
|
||||
StackFrame(number: -1, className: '<unknown>', method: r'main$', packageScheme: 'package', package: 'assertions', packagePath: 'main.dart', line: 8, column: 5, source: r'package:assertions/main.dart 8:5 main$'),
|
||||
StackFrame(number: -1, className: '<unknown>', method: r'main$', packageScheme: 'package', package: 'assertions', packagePath: 'main_web_entrypoint.dart', line: 9, column: 3, source: r'package:assertions/main_web_entrypoint.dart 9:3 main$'),
|
||||
StackFrame(number: -1, className: '<unknown>', method: 'onValue', packageScheme: 'package', package: 'dart-sdk', packagePath: 'lib/_internal/js_dev_runtime/patch/async_patch.dart', line: 47, column: 50, source: 'package:dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 47:50 onValue'),
|
||||
StackFrame(number: -1, className: '<unknown>', method: 'runUnary', packageScheme: 'package', package: 'dart-sdk', packagePath: 'lib/async/zone.dart', line: 1381, column: 54, source: 'package:dart-sdk/lib/async/zone.dart 1381:54 runUnary'),
|
||||
StackFrame(number: -1, className: '<unknown>', method: 'performLayout', packageScheme: '<unknown>', package: '<unknown>', packagePath: '<unknown>', line: 210, column: 5, source: 'object_test.dart 210:5 performLayout'),
|
||||
StackFrame(number: -1, className: '<unknown>', method: 'handleValue', packageScheme: 'package', package: 'dart-sdk', packagePath: 'lib/async/future_impl.dart', line: 140, column: 18, source: 'package:dart-sdk/lib/async/future_impl.dart 140:18 handleValue'),
|
||||
StackFrame(number: -1, className: '<unknown>', method: 'handleValueCallback', packageScheme: 'package', package: 'dart-sdk', packagePath: 'lib/async/future_impl.dart', line: 682, column: 44, source: 'package:dart-sdk/lib/async/future_impl.dart 682:44 handleValueCallback'),
|
||||
StackFrame(number: -1, className: '<unknown>', method: '_propagateToListeners', packageScheme: 'package', package: 'dart-sdk', packagePath: 'lib/async/future_impl.dart', line: 711, column: 32, source: 'package:dart-sdk/lib/async/future_impl.dart 711:32 _propagateToListeners'),
|
||||
StackFrame(number: -1, className: '<unknown>', method: 'callback', packageScheme: 'package', package: 'dart-sdk', packagePath: 'lib/async/future_impl.dart', line: 391, column: 9, source: 'package:dart-sdk/lib/async/future_impl.dart 391:9 callback'),
|
||||
StackFrame(number: -1, className: '<unknown>', method: '_microtaskLoop', packageScheme: 'package', package: 'dart-sdk', packagePath: 'lib/async/schedule_microtask.dart', line: 43, column: 11, source: 'package:dart-sdk/lib/async/schedule_microtask.dart 43:11 _microtaskLoop'),
|
||||
StackFrame(number: -1, className: '<unknown>', method: '_startMicrotaskLoop', packageScheme: 'package', package: 'dart-sdk', packagePath: 'lib/async/schedule_microtask.dart', line: 52, column: 5, source: 'package:dart-sdk/lib/async/schedule_microtask.dart 52:5 _startMicrotaskLoop'),
|
||||
StackFrame(number: -1, className: '<unknown>', method: '<fn>', packageScheme: 'package', package: 'dart-sdk', packagePath: 'lib/_internal/js_dev_runtime/patch/async_patch.dart', line: 168, column: 15, source: 'package:dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 168:15 <fn>'),
|
||||
];
|
Loading…
x
Reference in New Issue
Block a user