Remove unused FlutterErrorDetails subclasses (#61579)
This commit is contained in:
parent
c6dce2318b
commit
d1411a1626
@ -80,18 +80,17 @@ class PointerRouter {
|
|||||||
InformationCollector collector;
|
InformationCollector collector;
|
||||||
assert(() {
|
assert(() {
|
||||||
collector = () sync* {
|
collector = () sync* {
|
||||||
yield DiagnosticsProperty<PointerEvent>('Event', event, style: DiagnosticsTreeStyle.errorProperty);
|
yield DiagnosticsProperty<PointerRouter>('router', this, level: DiagnosticLevel.debug);
|
||||||
|
yield DiagnosticsProperty<PointerRoute>('route', route, level: DiagnosticLevel.debug);
|
||||||
|
yield DiagnosticsProperty<PointerEvent>('event', event, level: DiagnosticLevel.debug);
|
||||||
};
|
};
|
||||||
return true;
|
return true;
|
||||||
}());
|
}());
|
||||||
FlutterError.reportError(FlutterErrorDetailsForPointerRouter(
|
FlutterError.reportError(FlutterErrorDetails(
|
||||||
exception: exception,
|
exception: exception,
|
||||||
stack: stack,
|
stack: stack,
|
||||||
library: 'gesture library',
|
library: 'gesture library',
|
||||||
context: ErrorDescription('while routing a pointer event'),
|
context: ErrorDescription('while routing a pointer event'),
|
||||||
router: this,
|
|
||||||
route: route,
|
|
||||||
event: event,
|
|
||||||
informationCollector: collector
|
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;
|
|
||||||
}
|
|
||||||
|
@ -242,11 +242,10 @@ mixin DebugOverflowIndicatorMixin on RenderObject {
|
|||||||
// TODO(jacobr): add the overflows in pixels as structured data so they can
|
// TODO(jacobr): add the overflows in pixels as structured data so they can
|
||||||
// be visualized in debugging tools.
|
// be visualized in debugging tools.
|
||||||
FlutterError.reportError(
|
FlutterError.reportError(
|
||||||
FlutterErrorDetailsForRendering(
|
FlutterErrorDetails(
|
||||||
exception: FlutterError('A $runtimeType overflowed by $overflowText.'),
|
exception: FlutterError('A $runtimeType overflowed by $overflowText.'),
|
||||||
library: 'rendering library',
|
library: 'rendering library',
|
||||||
context: ErrorDescription('during layout'),
|
context: ErrorDescription('during layout'),
|
||||||
renderObject: this,
|
|
||||||
informationCollector: () sync* {
|
informationCollector: () sync* {
|
||||||
if (debugCreator != null)
|
if (debugCreator != null)
|
||||||
yield DiagnosticsDebugCreator(debugCreator);
|
yield DiagnosticsDebugCreator(debugCreator);
|
||||||
|
@ -1319,12 +1319,11 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
|
|||||||
dynamic debugCreator;
|
dynamic debugCreator;
|
||||||
|
|
||||||
void _debugReportException(String method, dynamic exception, StackTrace stack) {
|
void _debugReportException(String method, dynamic exception, StackTrace stack) {
|
||||||
FlutterError.reportError(FlutterErrorDetailsForRendering(
|
FlutterError.reportError(FlutterErrorDetails(
|
||||||
exception: exception,
|
exception: exception,
|
||||||
stack: stack,
|
stack: stack,
|
||||||
library: 'rendering library',
|
library: 'rendering library',
|
||||||
context: ErrorDescription('during $method()'),
|
context: ErrorDescription('during $method()'),
|
||||||
renderObject: this,
|
|
||||||
informationCollector: () sync* {
|
informationCollector: () sync* {
|
||||||
if (debugCreator != null)
|
if (debugCreator != null)
|
||||||
yield DiagnosticsDebugCreator(debugCreator);
|
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
|
/// Describes the semantics information a [RenderObject] wants to add to its
|
||||||
/// parent.
|
/// parent.
|
||||||
///
|
///
|
||||||
|
@ -153,6 +153,17 @@ void main() {
|
|||||||
FlutterError.onError = previousErrorHandler;
|
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', () {
|
test('Should transform events', () {
|
||||||
final List<PointerEvent> events = <PointerEvent>[];
|
final List<PointerEvent> events = <PointerEvent>[];
|
||||||
final List<PointerEvent> globalEvents = <PointerEvent>[];
|
final List<PointerEvent> globalEvents = <PointerEvent>[];
|
||||||
|
@ -47,7 +47,7 @@ class StructuredErrorTestService extends TestWidgetInspectorService {
|
|||||||
expect(flutterErrorEvents, hasLength(0));
|
expect(flutterErrorEvents, hasLength(0));
|
||||||
|
|
||||||
// Create an error.
|
// Create an error.
|
||||||
FlutterError.reportError(FlutterErrorDetailsForRendering(
|
FlutterError.reportError(FlutterErrorDetails(
|
||||||
library: 'rendering library',
|
library: 'rendering library',
|
||||||
context: ErrorDescription('during layout'),
|
context: ErrorDescription('during layout'),
|
||||||
exception: StackTrace.current,
|
exception: StackTrace.current,
|
||||||
|
@ -76,7 +76,7 @@ class StructureErrorTestWidgetInspectorService extends Object with WidgetInspect
|
|||||||
equals('true'));
|
equals('true'));
|
||||||
|
|
||||||
// Creates an error.
|
// Creates an error.
|
||||||
final FlutterErrorDetails expectedError = FlutterErrorDetailsForRendering(
|
final FlutterErrorDetails expectedError = FlutterErrorDetails(
|
||||||
library: 'rendering library',
|
library: 'rendering library',
|
||||||
context: ErrorDescription('during layout'),
|
context: ErrorDescription('during layout'),
|
||||||
exception: StackTrace.current,
|
exception: StackTrace.current,
|
||||||
|
@ -2356,7 +2356,7 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {
|
|||||||
equals('true'));
|
equals('true'));
|
||||||
|
|
||||||
// Create an error.
|
// Create an error.
|
||||||
FlutterError.reportError(FlutterErrorDetailsForRendering(
|
FlutterError.reportError(FlutterErrorDetails(
|
||||||
library: 'rendering library',
|
library: 'rendering library',
|
||||||
context: ErrorDescription('during layout'),
|
context: ErrorDescription('during layout'),
|
||||||
exception: StackTrace.current,
|
exception: StackTrace.current,
|
||||||
@ -2379,7 +2379,7 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {
|
|||||||
'══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞════════════'));
|
'══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞════════════'));
|
||||||
|
|
||||||
// Send a second error.
|
// Send a second error.
|
||||||
FlutterError.reportError(FlutterErrorDetailsForRendering(
|
FlutterError.reportError(FlutterErrorDetails(
|
||||||
library: 'rendering library',
|
library: 'rendering library',
|
||||||
context: ErrorDescription('also during layout'),
|
context: ErrorDescription('also during layout'),
|
||||||
exception: StackTrace.current,
|
exception: StackTrace.current,
|
||||||
@ -2407,7 +2407,7 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {
|
|||||||
binding.postTest();
|
binding.postTest();
|
||||||
|
|
||||||
// Send another error.
|
// Send another error.
|
||||||
FlutterError.reportError(FlutterErrorDetailsForRendering(
|
FlutterError.reportError(FlutterErrorDetails(
|
||||||
library: 'rendering library',
|
library: 'rendering library',
|
||||||
context: ErrorDescription('during layout'),
|
context: ErrorDescription('during layout'),
|
||||||
exception: StackTrace.current,
|
exception: StackTrace.current,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user