Unverified Commit aa9ca8fc authored by Danny Tuppeny's avatar Danny Tuppeny Committed by GitHub

Ensure user-thrown errors have ErrorSummary nodes (#36857)

parent 7c27142e
...@@ -411,7 +411,7 @@ class FlutterErrorDetails extends Diagnosticable { ...@@ -411,7 +411,7 @@ class FlutterErrorDetails extends Diagnosticable {
String message = exceptionAsString(); String message = exceptionAsString();
if (message.startsWith(prefix)) if (message.startsWith(prefix))
message = message.substring(prefix.length); message = message.substring(prefix.length);
properties.add(ErrorDescription('$message')); properties.add(ErrorSummary('$message'));
} }
} }
......
...@@ -328,4 +328,28 @@ void main() { ...@@ -328,4 +328,28 @@ void main() {
); );
} }
}); });
test('User-thrown exceptions have ErrorSummary properties', () {
{
DiagnosticsNode node;
try {
throw 'User thrown string';
} catch (e) {
node = FlutterErrorDetails(exception: e).toDiagnosticsNode();
}
final ErrorSummary summary = node.getProperties().whereType<ErrorSummary>().single;
expect(summary.value, equals(<String>['User thrown string']));
}
{
DiagnosticsNode node;
try {
throw ArgumentError.notNull('myArgument');
} catch (e) {
node = FlutterErrorDetails(exception: e).toDiagnosticsNode();
}
final ErrorSummary summary = node.getProperties().whereType<ErrorSummary>().single;
expect(summary.value, equals(<String>['Invalid argument(s) (myArgument): Must not be null']));
}
});
} }
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