handleWebAppError method
Handles an ERROR event from the web app (network, business logic,
onboarding, maintenance, etc.).
Contract: the ErrorEvent is ALWAYS published on the event stream (Flourish.onErrorEvent) for observers. Separately, if Flourish.onError is provided, the integrator takes over the UI and the default navigation is suppressed; otherwise the SDK falls back to FlourishTokenErrorPage, which renders a generic "something went wrong / contact support" screen (despite its name, it is not auth-specific).
Implementation
Future<void> handleWebAppError(Map<String, dynamic> json) async {
final errorEvent = ErrorEvent.fromJson(json);
_notify(errorEvent);
final onError = flourish.onError;
switch (resolveErrorPresentation(
isMounted: mounted, hasCallback: onError != null)) {
case ErrorPresentation.none:
return;
case ErrorPresentation.invokeCallback:
return onError!(context, errorEvent);
case ErrorPresentation.navigateToFallback:
return _replaceWithErrorPage(FlourishTokenErrorPage(flourish: flourish));
}
}