koolbaseDataErrorNotifying function
Builds the exception for a failed response and notifies onSessionExpired
when the server rejected the session token itself.
The notification happens before the exception is thrown, so by the time a caller catches KoolbaseSessionExpiredException the session is already cleared and the app can route to login without racing the SDK.
Shared by every client rather than duplicated: a path that forgot to notify would leave an app authenticated against a token the server refuses, which is the failure this exists to prevent.
Implementation
Future<KoolbaseException> koolbaseDataErrorNotifying(
http.Response res, {
String fallbackMessage = 'Request failed',
Future<void> Function()? onSessionExpired,
}) async {
final err =
koolbaseDataErrorFromResponse(res, fallbackMessage: fallbackMessage);
if (err is KoolbaseUnauthenticatedException) {
await onSessionExpired?.call();
}
return err;
}