From f512e86c2a210d8402e43a3352c1b2fcf4308a43 Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Fri, 14 Aug 2020 12:03:18 -0700 Subject: [PATCH] Use reportError (over onError) everywhere (#63784) --- .../flutter/lib/src/foundation/assertions.dart | 3 +++ .../flutter/lib/src/painting/image_provider.dart | 14 ++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/flutter/lib/src/foundation/assertions.dart b/packages/flutter/lib/src/foundation/assertions.dart index 86b68e79e9..375080a9f5 100644 --- a/packages/flutter/lib/src/foundation/assertions.dart +++ b/packages/flutter/lib/src/foundation/assertions.dart @@ -871,6 +871,9 @@ class FlutterError extends Error with DiagnosticableTreeMixin implements Asserti /// /// Set this to null to silently catch and ignore errors. This is not /// recommended. + /// + /// Do not call [onError] directly, instead, call [reportError], which + /// forwards to [onError] if it is not null. static FlutterExceptionHandler? onError = (FlutterErrorDetails details) => presentError(details); /// Called by the Flutter framework before attempting to parse a [StackTrace]. diff --git a/packages/flutter/lib/src/painting/image_provider.dart b/packages/flutter/lib/src/painting/image_provider.dart index 9e836ea30c..33167df42e 100644 --- a/packages/flutter/lib/src/painting/image_provider.dart +++ b/packages/flutter/lib/src/painting/image_provider.dart @@ -401,14 +401,12 @@ abstract class ImageProvider { }; return true; }()); - if (FlutterError.onError != null) { - FlutterError.onError!(FlutterErrorDetails( - context: ErrorDescription('while checking the cache location of an image'), - informationCollector: collector, - exception: exception, - stack: stack, - )); - } + FlutterError.reportError(FlutterErrorDetails( + context: ErrorDescription('while checking the cache location of an image'), + informationCollector: collector, + exception: exception, + stack: stack, + )); completer.complete(null); } },