Move away from deprecated NoSuchMethodError to NoSuchMethodError.withInvocation (#63974)

This commit is contained in:
Alexander Aprelev 2020-08-18 08:41:02 -07:00 committed by GitHub
parent 473744df2c
commit 61362cff85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -162,22 +162,24 @@ Future<void> main() async {
test('Error reporting - NoSuchMethodError', () async { test('Error reporting - NoSuchMethodError', () async {
expect(console, isEmpty); expect(console, isEmpty);
final dynamic exception = NoSuchMethodError(5, #foo, <dynamic>[2, 4], null); // ignore: deprecated_member_use final dynamic exception = NoSuchMethodError.withInvocation(5,
Invocation.method(#foo, <dynamic>[2, 4]));
FlutterError.dumpErrorToConsole(FlutterErrorDetails( FlutterError.dumpErrorToConsole(FlutterErrorDetails(
exception: exception, exception: exception,
)); ));
expect(console.join('\n'), matches( expect(console.join('\n'), matches(
r'^══╡ EXCEPTION CAUGHT BY FLUTTER FRAMEWORK ╞═════════════════════════════════════════════════════════\n' r'^══╡ EXCEPTION CAUGHT BY FLUTTER FRAMEWORK ╞═════════════════════════════════════════════════════════\n'
r'The following NoSuchMethodError was thrown:\n' r'The following NoSuchMethodError was thrown:\n'
r'Receiver: 5\n' r'int has no foo method accepting arguments \(_, _\)\n'
r'Tried calling: foo = 2, 4\n'
r'════════════════════════════════════════════════════════════════════════════════════════════════════$', r'════════════════════════════════════════════════════════════════════════════════════════════════════$',
)); ));
console.clear(); console.clear();
FlutterError.dumpErrorToConsole(FlutterErrorDetails( FlutterError.dumpErrorToConsole(FlutterErrorDetails(
exception: exception, exception: exception,
)); ));
expect(console.join('\n'), 'Another exception was thrown: NoSuchMethodError: Receiver: 5'); expect(console.join('\n'),
'Another exception was thrown: NoSuchMethodError: int has no foo method accepting arguments (_, _)');
console.clear(); console.clear();
FlutterError.resetErrorCount(); FlutterError.resetErrorCount();
}); });