Unverified Commit 61362cff authored by Alexander Aprelev's avatar Alexander Aprelev Committed by GitHub

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

parent 473744df
...@@ -162,22 +162,24 @@ Future<void> main() async { ...@@ -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();
}); });
......
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