onError method

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

Called when an exception was occurred during the request.

Implementation

@override
Future<void> onError(
  DioException err,
  ErrorInterceptorHandler handler,
) async {
  if (_shouldRetry(err)) {
    try {
      return handler.resolve(
        await _requestRetrier.scheduleRequestRetry(err.requestOptions),
      );
    } on DioException catch (e) {
      // Let any new error from the retrier pass through
      return handler.reject(e);
    }
  }

  return handler.next(err);
}