onError method

  1. @override
void onError(
  1. DioException err,
  2. ErrorInterceptorHandler handler
)
override

Intercepts Dio errors and triggers an auth failure notification when the error is an UnauthorizedException.

Applies a 2-second debounce so that concurrent requests failing with 401 produce only a single notification. The error is always forwarded via handler.next regardless of the notification outcome.

Implementation

@override
void onError(DioException err, ErrorInterceptorHandler handler) {
  if (err.error is UnauthorizedException) {
    _notifyOnceDebounced();
    Sentry.metrics.count('auth.session.revoked', 1);
  }

  handler.next(err);
}