Skip to content

Commit d1411a1

Browse files
authored
Remove unused FlutterErrorDetails subclasses (flutter#61579)
1 parent c6dce23 commit d1411a1

7 files changed

+22
-88
lines changed

packages/flutter/lib/src/gestures/pointer_router.dart

+4-50
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,17 @@ class PointerRouter {
8080
InformationCollector collector;
8181
assert(() {
8282
collector = () sync* {
83-
yield DiagnosticsProperty<PointerEvent>('Event', event, style: DiagnosticsTreeStyle.errorProperty);
83+
yield DiagnosticsProperty<PointerRouter>('router', this, level: DiagnosticLevel.debug);
84+
yield DiagnosticsProperty<PointerRoute>('route', route, level: DiagnosticLevel.debug);
85+
yield DiagnosticsProperty<PointerEvent>('event', event, level: DiagnosticLevel.debug);
8486
};
8587
return true;
8688
}());
87-
FlutterError.reportError(FlutterErrorDetailsForPointerRouter(
89+
FlutterError.reportError(FlutterErrorDetails(
8890
exception: exception,
8991
stack: stack,
9092
library: 'gesture library',
9193
context: ErrorDescription('while routing a pointer event'),
92-
router: this,
93-
route: route,
94-
event: event,
9594
informationCollector: collector
9695
));
9796
}
@@ -126,48 +125,3 @@ class PointerRouter {
126125
});
127126
}
128127
}
129-
130-
/// Variant of [FlutterErrorDetails] with extra fields for the gestures
131-
/// library's pointer router ([PointerRouter]).
132-
///
133-
/// See also:
134-
///
135-
/// * [FlutterErrorDetailsForPointerEventDispatcher], which is also used
136-
/// by the gestures library.
137-
class FlutterErrorDetailsForPointerRouter extends FlutterErrorDetails {
138-
/// Creates a [FlutterErrorDetailsForPointerRouter] object with the given
139-
/// arguments setting the object's properties.
140-
///
141-
/// The gestures library calls this constructor when catching an exception
142-
/// that will subsequently be reported using [FlutterError.onError].
143-
const FlutterErrorDetailsForPointerRouter({
144-
dynamic exception,
145-
StackTrace stack,
146-
String library,
147-
DiagnosticsNode context,
148-
this.router,
149-
this.route,
150-
this.event,
151-
InformationCollector informationCollector,
152-
bool silent = false,
153-
}) : super(
154-
exception: exception,
155-
stack: stack,
156-
library: library,
157-
context: context,
158-
informationCollector: informationCollector,
159-
silent: silent,
160-
);
161-
162-
/// The pointer router that caught the exception.
163-
///
164-
/// In a typical application, this is the value of [GestureBinding.pointerRouter] on
165-
/// the binding ([GestureBinding.instance]).
166-
final PointerRouter router;
167-
168-
/// The callback that threw the exception.
169-
final PointerRoute route;
170-
171-
/// The pointer event that was being routed when the exception was raised.
172-
final PointerEvent event;
173-
}

packages/flutter/lib/src/rendering/debug_overflow_indicator.dart

+1-2
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,10 @@ mixin DebugOverflowIndicatorMixin on RenderObject {
242242
// TODO(jacobr): add the overflows in pixels as structured data so they can
243243
// be visualized in debugging tools.
244244
FlutterError.reportError(
245-
FlutterErrorDetailsForRendering(
245+
FlutterErrorDetails(
246246
exception: FlutterError('A $runtimeType overflowed by $overflowText.'),
247247
library: 'rendering library',
248248
context: ErrorDescription('during layout'),
249-
renderObject: this,
250249
informationCollector: () sync* {
251250
if (debugCreator != null)
252251
yield DiagnosticsDebugCreator(debugCreator);

packages/flutter/lib/src/rendering/object.dart

+1-31
Original file line numberDiff line numberDiff line change
@@ -1319,12 +1319,11 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
13191319
dynamic debugCreator;
13201320

13211321
void _debugReportException(String method, dynamic exception, StackTrace stack) {
1322-
FlutterError.reportError(FlutterErrorDetailsForRendering(
1322+
FlutterError.reportError(FlutterErrorDetails(
13231323
exception: exception,
13241324
stack: stack,
13251325
library: 'rendering library',
13261326
context: ErrorDescription('during $method()'),
1327-
renderObject: this,
13281327
informationCollector: () sync* {
13291328
if (debugCreator != null)
13301329
yield DiagnosticsDebugCreator(debugCreator);
@@ -3384,35 +3383,6 @@ mixin RelayoutWhenSystemFontsChangeMixin on RenderObject {
33843383
}
33853384
}
33863385

3387-
/// Variant of [FlutterErrorDetails] with extra fields for the rendering
3388-
/// library.
3389-
class FlutterErrorDetailsForRendering extends FlutterErrorDetails {
3390-
/// Creates a [FlutterErrorDetailsForRendering] object with the given
3391-
/// arguments setting the object's properties.
3392-
///
3393-
/// The rendering library calls this constructor when catching an exception
3394-
/// that will subsequently be reported using [FlutterError.onError].
3395-
const FlutterErrorDetailsForRendering({
3396-
dynamic exception,
3397-
StackTrace stack,
3398-
String library,
3399-
DiagnosticsNode context,
3400-
this.renderObject,
3401-
InformationCollector informationCollector,
3402-
bool silent = false,
3403-
}) : super(
3404-
exception: exception,
3405-
stack: stack,
3406-
library: library,
3407-
context: context,
3408-
informationCollector: informationCollector,
3409-
silent: silent,
3410-
);
3411-
3412-
/// The RenderObject that was being processed when the exception was caught.
3413-
final RenderObject renderObject;
3414-
}
3415-
34163386
/// Describes the semantics information a [RenderObject] wants to add to its
34173387
/// parent.
34183388
///

packages/flutter/test/gestures/pointer_router_test.dart

+11
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,17 @@ void main() {
153153
FlutterError.onError = previousErrorHandler;
154154
});
155155

156+
test('Exceptions include router, route & event', () {
157+
try {
158+
final PointerRouter router = PointerRouter();
159+
router.addRoute(2, (PointerEvent event) => throw 'Pointer exception');
160+
} catch (e) {
161+
expect(e, contains('router: Instance of \'PointerRouter\''));
162+
expect(e, contains('route: Closure: (PointerEvent) => Null'));
163+
expect(e, contains('event: PointerDownEvent#[a-zA-Z0-9]{5}(position: Offset(0.0, 0.0))'));
164+
}
165+
});
166+
156167
test('Should transform events', () {
157168
final List<PointerEvent> events = <PointerEvent>[];
158169
final List<PointerEvent> globalEvents = <PointerEvent>[];

packages/flutter/test/widgets/widget_inspector_init_with_structured_error_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class StructuredErrorTestService extends TestWidgetInspectorService {
4747
expect(flutterErrorEvents, hasLength(0));
4848

4949
// Create an error.
50-
FlutterError.reportError(FlutterErrorDetailsForRendering(
50+
FlutterError.reportError(FlutterErrorDetails(
5151
library: 'rendering library',
5252
context: ErrorDescription('during layout'),
5353
exception: StackTrace.current,

packages/flutter/test/widgets/widget_inspector_structure_error_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class StructureErrorTestWidgetInspectorService extends Object with WidgetInspect
7676
equals('true'));
7777

7878
// Creates an error.
79-
final FlutterErrorDetails expectedError = FlutterErrorDetailsForRendering(
79+
final FlutterErrorDetails expectedError = FlutterErrorDetails(
8080
library: 'rendering library',
8181
context: ErrorDescription('during layout'),
8282
exception: StackTrace.current,

packages/flutter/test/widgets/widget_inspector_test.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -2356,7 +2356,7 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {
23562356
equals('true'));
23572357

23582358
// Create an error.
2359-
FlutterError.reportError(FlutterErrorDetailsForRendering(
2359+
FlutterError.reportError(FlutterErrorDetails(
23602360
library: 'rendering library',
23612361
context: ErrorDescription('during layout'),
23622362
exception: StackTrace.current,
@@ -2379,7 +2379,7 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {
23792379
'══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞════════════'));
23802380

23812381
// Send a second error.
2382-
FlutterError.reportError(FlutterErrorDetailsForRendering(
2382+
FlutterError.reportError(FlutterErrorDetails(
23832383
library: 'rendering library',
23842384
context: ErrorDescription('also during layout'),
23852385
exception: StackTrace.current,
@@ -2407,7 +2407,7 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {
24072407
binding.postTest();
24082408

24092409
// Send another error.
2410-
FlutterError.reportError(FlutterErrorDetailsForRendering(
2410+
FlutterError.reportError(FlutterErrorDetails(
24112411
library: 'rendering library',
24122412
context: ErrorDescription('during layout'),
24132413
exception: StackTrace.current,

0 commit comments

Comments
 (0)