fromException static method
Implementation
static NetworkError fromException(error) {
try {
if (error is Exception) {
NetworkError networkExceptions;
if (error is DioException) {
networkExceptions = getErrorFromDioError(error);
} else if (error is SocketException) {
networkExceptions = const NetworkError.noInternetConnection();
} else {
networkExceptions = const NetworkError.unexpectedError();
}
return networkExceptions;
} else if (error is FormatException) {
return const NetworkError.formatException();
} else {
return error.toString().contains('is not a subtype of')
? const NetworkError.unableToProcess()
: const NetworkError.unexpectedError();
}
} catch (_) {
return const NetworkError.unexpectedError();
}
}