isOfflineError method

  1. @protected
  2. @visibleForTesting
bool isOfflineError(
  1. Object? error
)
inherited

Determines whether error was an offline error.

Implementation

@protected
@visibleForTesting
bool isOfflineError(Object? error) {
  final commonExceptions = [
    // timeouts via http's `connectionTimeout` are also socket exceptions
    'SocketException',
    'HttpException',
    'HandshakeException',
    'TimeoutException',
  ];

  // we check exceptions with strings to avoid importing `dart:io`
  final err = error.runtimeType.toString();
  return commonExceptions.any(err.contains);
}