executeDownloadOrThrow<T> static method

Future<T> executeDownloadOrThrow<T>(
  1. List<YKInterceptor> interceptors,
  2. int maxRetries,
  3. YKNetworkingRequest request, {
  4. int retryCount = 0,
  5. Set<String>? retrySkipNames,
})

Throwing variant of executeDownload.

Returns T directly on success, throws YKNetworkException on failure or cancellation.

Implementation

static Future<T> executeDownloadOrThrow<T>(
  List<YKInterceptor> interceptors,
  int maxRetries,
  YKNetworkingRequest request, {
  int retryCount = 0,
  Set<String>? retrySkipNames,
}) async {
  final result = await executeDownload<T>(interceptors, maxRetries, request,
    retryCount: retryCount, retrySkipNames: retrySkipNames);
  switch (result) {
    case YKSuccess(:final data):
      return data;
    case YKFailure(:final exception):
      throw exception;
    case YKCancelled(:final reason):
      throw YKNetworkException(type: YKErrorType.cancelled, message: reason);
  }
}