onError method

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

Called when an exception was occurred during the request.

Implementation

@override
void onError(DioException err, ErrorInterceptorHandler handler) {
  if (err.requestOptions.extra['like.synthetic'] == true) {
    handler.next(err);
    return;
  }
  // Dio routes rejected HTTP status responses through onError. They are still
  // positive reachability evidence and must never launch another probe.
  if (err.response != null) {
    LikeConnectivityManager().markServerAvailable(
      serverUrl: err.requestOptions.uri.toString(),
    );
  } else if (_shouldCheckAfter(err) && !LikeRetryInterceptor.willRetry(err)) {
    // Diagnose terminal transport failures immediately with force: true
    LikeConnectivityManager().checkAfterApiFailure(
      err.requestOptions.uri.toString(),
      force: true,
    );
  }
  handler.next(err);
}