reportFailure function
Reports a failure in one consistent way: to telemetry and, for route-level failures, as a RouteFailureEvent.
Call this once per failure, where it is detected, not from build.
Implementation
void reportFailure(VyuhFailure failure, {bool emitRouteEvent = true}) {
try {
vyuh.telemetry.reportError(
failure.error ?? failure.title,
stackTrace: failure.stackTrace,
);
} catch (_) {
// Telemetry may not be ready, for example during an init failure.
}
if (!emitRouteEvent) return;
try {
vyuh.event.emit(RouteFailureEvent(failure));
} catch (_) {
// The event plugin may not be ready.
}
}