From d1411a1626477e486544fb620f2e9226676f6e1d Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Fri, 24 Jul 2020 15:36:08 -0700 Subject: [PATCH] Remove unused FlutterErrorDetails subclasses (#61579) --- .../lib/src/gestures/pointer_router.dart | 54 ++----------------- .../rendering/debug_overflow_indicator.dart | 3 +- .../flutter/lib/src/rendering/object.dart | 32 +---------- .../test/gestures/pointer_router_test.dart | 11 ++++ ...ector_init_with_structured_error_test.dart | 2 +- ...widget_inspector_structure_error_test.dart | 2 +- .../test/widgets/widget_inspector_test.dart | 6 +-- 7 files changed, 22 insertions(+), 88 deletions(-) diff --git a/packages/flutter/lib/src/gestures/pointer_router.dart b/packages/flutter/lib/src/gestures/pointer_router.dart index a832609985..eec4fd4df7 100644 --- a/packages/flutter/lib/src/gestures/pointer_router.dart +++ b/packages/flutter/lib/src/gestures/pointer_router.dart @@ -80,18 +80,17 @@ class PointerRouter { InformationCollector collector; assert(() { collector = () sync* { - yield DiagnosticsProperty('Event', event, style: DiagnosticsTreeStyle.errorProperty); + yield DiagnosticsProperty('router', this, level: DiagnosticLevel.debug); + yield DiagnosticsProperty('route', route, level: DiagnosticLevel.debug); + yield DiagnosticsProperty('event', event, level: DiagnosticLevel.debug); }; return true; }()); - FlutterError.reportError(FlutterErrorDetailsForPointerRouter( + FlutterError.reportError(FlutterErrorDetails( exception: exception, stack: stack, library: 'gesture library', context: ErrorDescription('while routing a pointer event'), - router: this, - route: route, - event: event, informationCollector: collector )); } @@ -126,48 +125,3 @@ class PointerRouter { }); } } - -/// Variant of [FlutterErrorDetails] with extra fields for the gestures -/// library's pointer router ([PointerRouter]). -/// -/// See also: -/// -/// * [FlutterErrorDetailsForPointerEventDispatcher], which is also used -/// by the gestures library. -class FlutterErrorDetailsForPointerRouter extends FlutterErrorDetails { - /// Creates a [FlutterErrorDetailsForPointerRouter] object with the given - /// arguments setting the object's properties. - /// - /// The gestures library calls this constructor when catching an exception - /// that will subsequently be reported using [FlutterError.onError]. - const FlutterErrorDetailsForPointerRouter({ - dynamic exception, - StackTrace stack, - String library, - DiagnosticsNode context, - this.router, - this.route, - this.event, - InformationCollector informationCollector, - bool silent = false, - }) : super( - exception: exception, - stack: stack, - library: library, - context: context, - informationCollector: informationCollector, - silent: silent, - ); - - /// The pointer router that caught the exception. - /// - /// In a typical application, this is the value of [GestureBinding.pointerRouter] on - /// the binding ([GestureBinding.instance]). - final PointerRouter router; - - /// The callback that threw the exception. - final PointerRoute route; - - /// The pointer event that was being routed when the exception was raised. - final PointerEvent event; -} diff --git a/packages/flutter/lib/src/rendering/debug_overflow_indicator.dart b/packages/flutter/lib/src/rendering/debug_overflow_indicator.dart index 1acd095a48..73cfac1dbf 100644 --- a/packages/flutter/lib/src/rendering/debug_overflow_indicator.dart +++ b/packages/flutter/lib/src/rendering/debug_overflow_indicator.dart @@ -242,11 +242,10 @@ mixin DebugOverflowIndicatorMixin on RenderObject { // TODO(jacobr): add the overflows in pixels as structured data so they can // be visualized in debugging tools. FlutterError.reportError( - FlutterErrorDetailsForRendering( + FlutterErrorDetails( exception: FlutterError('A $runtimeType overflowed by $overflowText.'), library: 'rendering library', context: ErrorDescription('during layout'), - renderObject: this, informationCollector: () sync* { if (debugCreator != null) yield DiagnosticsDebugCreator(debugCreator); diff --git a/packages/flutter/lib/src/rendering/object.dart b/packages/flutter/lib/src/rendering/object.dart index 0c76cb932c..2bc752c240 100644 --- a/packages/flutter/lib/src/rendering/object.dart +++ b/packages/flutter/lib/src/rendering/object.dart @@ -1319,12 +1319,11 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im dynamic debugCreator; void _debugReportException(String method, dynamic exception, StackTrace stack) { - FlutterError.reportError(FlutterErrorDetailsForRendering( + FlutterError.reportError(FlutterErrorDetails( exception: exception, stack: stack, library: 'rendering library', context: ErrorDescription('during $method()'), - renderObject: this, informationCollector: () sync* { if (debugCreator != null) yield DiagnosticsDebugCreator(debugCreator); @@ -3384,35 +3383,6 @@ mixin RelayoutWhenSystemFontsChangeMixin on RenderObject { } } -/// Variant of [FlutterErrorDetails] with extra fields for the rendering -/// library. -class FlutterErrorDetailsForRendering extends FlutterErrorDetails { - /// Creates a [FlutterErrorDetailsForRendering] object with the given - /// arguments setting the object's properties. - /// - /// The rendering library calls this constructor when catching an exception - /// that will subsequently be reported using [FlutterError.onError]. - const FlutterErrorDetailsForRendering({ - dynamic exception, - StackTrace stack, - String library, - DiagnosticsNode context, - this.renderObject, - InformationCollector informationCollector, - bool silent = false, - }) : super( - exception: exception, - stack: stack, - library: library, - context: context, - informationCollector: informationCollector, - silent: silent, - ); - - /// The RenderObject that was being processed when the exception was caught. - final RenderObject renderObject; -} - /// Describes the semantics information a [RenderObject] wants to add to its /// parent. /// diff --git a/packages/flutter/test/gestures/pointer_router_test.dart b/packages/flutter/test/gestures/pointer_router_test.dart index 07cef48c76..dc2dcd3a08 100644 --- a/packages/flutter/test/gestures/pointer_router_test.dart +++ b/packages/flutter/test/gestures/pointer_router_test.dart @@ -153,6 +153,17 @@ void main() { FlutterError.onError = previousErrorHandler; }); + test('Exceptions include router, route & event', () { + try { + final PointerRouter router = PointerRouter(); + router.addRoute(2, (PointerEvent event) => throw 'Pointer exception'); + } catch (e) { + expect(e, contains('router: Instance of \'PointerRouter\'')); + expect(e, contains('route: Closure: (PointerEvent) => Null')); + expect(e, contains('event: PointerDownEvent#[a-zA-Z0-9]{5}(position: Offset(0.0, 0.0))')); + } + }); + test('Should transform events', () { final List events = []; final List globalEvents = []; diff --git a/packages/flutter/test/widgets/widget_inspector_init_with_structured_error_test.dart b/packages/flutter/test/widgets/widget_inspector_init_with_structured_error_test.dart index 3053570f19..41b78e57dd 100644 --- a/packages/flutter/test/widgets/widget_inspector_init_with_structured_error_test.dart +++ b/packages/flutter/test/widgets/widget_inspector_init_with_structured_error_test.dart @@ -47,7 +47,7 @@ class StructuredErrorTestService extends TestWidgetInspectorService { expect(flutterErrorEvents, hasLength(0)); // Create an error. - FlutterError.reportError(FlutterErrorDetailsForRendering( + FlutterError.reportError(FlutterErrorDetails( library: 'rendering library', context: ErrorDescription('during layout'), exception: StackTrace.current, diff --git a/packages/flutter/test/widgets/widget_inspector_structure_error_test.dart b/packages/flutter/test/widgets/widget_inspector_structure_error_test.dart index bf05b098a7..2740746b2d 100644 --- a/packages/flutter/test/widgets/widget_inspector_structure_error_test.dart +++ b/packages/flutter/test/widgets/widget_inspector_structure_error_test.dart @@ -76,7 +76,7 @@ class StructureErrorTestWidgetInspectorService extends Object with WidgetInspect equals('true')); // Creates an error. - final FlutterErrorDetails expectedError = FlutterErrorDetailsForRendering( + final FlutterErrorDetails expectedError = FlutterErrorDetails( library: 'rendering library', context: ErrorDescription('during layout'), exception: StackTrace.current, diff --git a/packages/flutter/test/widgets/widget_inspector_test.dart b/packages/flutter/test/widgets/widget_inspector_test.dart index a0ae9e16ca..1f9a16e741 100644 --- a/packages/flutter/test/widgets/widget_inspector_test.dart +++ b/packages/flutter/test/widgets/widget_inspector_test.dart @@ -2356,7 +2356,7 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService { equals('true')); // Create an error. - FlutterError.reportError(FlutterErrorDetailsForRendering( + FlutterError.reportError(FlutterErrorDetails( library: 'rendering library', context: ErrorDescription('during layout'), exception: StackTrace.current, @@ -2379,7 +2379,7 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService { '══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞════════════')); // Send a second error. - FlutterError.reportError(FlutterErrorDetailsForRendering( + FlutterError.reportError(FlutterErrorDetails( library: 'rendering library', context: ErrorDescription('also during layout'), exception: StackTrace.current, @@ -2407,7 +2407,7 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService { binding.postTest(); // Send another error. - FlutterError.reportError(FlutterErrorDetailsForRendering( + FlutterError.reportError(FlutterErrorDetails( library: 'rendering library', context: ErrorDescription('during layout'), exception: StackTrace.current,