ErrorInterceptor class
Intercepts errors from all three Flutter/Dart error zones and emits CausalEvents to the TrinityEventBus.
The Three Error Zones
| Zone | What it catches | Hook |
|---|---|---|
| Flutter Framework | Widget build errors, setState after dispose | FlutterError.onError |
| Platform Dispatcher | Unhandled async Future rejections | PlatformDispatcher.instance.onError |
| Dart Zone | Legacy async errors via runZonedGuarded |
Passed as zonedErrorHandler |
Usage
Call initialize once in main() before runApp():
void main() {
runZonedGuarded(() {
WidgetsFlutterBinding.ensureInitialized();
ErrorInterceptor.initialize();
runApp(RecoverableApp(child: MyApp()));
}, ErrorInterceptor.handleZoneError);
}
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- onError ↔ ErrorCallback?
-
Optional external callback — called in addition to emitting to the bus.
getter/setter pair
Static Methods
-
debugReset(
) → void - Resets initialization state. For testing only.
-
handleZoneError(
Object error, StackTrace stack) → void -
Handler for
runZonedGuarded— pass this as the second argument torunZonedGuarded()in yourmain(). -
initialize(
{ErrorCallback? errorCallback}) → void - Sets up error interception for all three error zones.