DownloadError -> DataTransferError
This commit is contained in:
parent
213d124277
commit
c4c1ae0a00
|
@ -690,7 +690,7 @@ std::pair<bool, std::string> EvalState::resolveSearchPathElem(const SearchPathEl
|
|||
try {
|
||||
res = { true, store->toRealPath(fetchers::downloadTarball(
|
||||
store, resolveUri(elem.second), "source", false).storePath) };
|
||||
} catch (DownloadError & e) {
|
||||
} catch (DataTransferError & e) {
|
||||
printError(format("warning: Nix search path entry '%1%' cannot be downloaded, ignoring") % elem.second);
|
||||
res = { false, "" };
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ struct curlDataTransfer : public DataTransfer
|
|||
if (requestHeaders) curl_slist_free_all(requestHeaders);
|
||||
try {
|
||||
if (!done)
|
||||
fail(DownloadError(Interrupted, format("download of '%s' was interrupted") % request.uri));
|
||||
fail(DataTransferError(Interrupted, format("download of '%s' was interrupted") % request.uri));
|
||||
} catch (...) {
|
||||
ignoreException();
|
||||
}
|
||||
|
@ -401,14 +401,14 @@ struct curlDataTransfer : public DataTransfer
|
|||
|
||||
auto exc =
|
||||
code == CURLE_ABORTED_BY_CALLBACK && _isInterrupted
|
||||
? DownloadError(Interrupted, fmt("%s of '%s' was interrupted", request.verb(), request.uri))
|
||||
? DataTransferError(Interrupted, fmt("%s of '%s' was interrupted", request.verb(), request.uri))
|
||||
: httpStatus != 0
|
||||
? DownloadError(err,
|
||||
? DataTransferError(err,
|
||||
fmt("unable to %s '%s': HTTP error %d",
|
||||
request.verb(), request.uri, httpStatus)
|
||||
+ (code == CURLE_OK ? "" : fmt(" (curl error: %s)", curl_easy_strerror(code)))
|
||||
)
|
||||
: DownloadError(err,
|
||||
: DataTransferError(err,
|
||||
fmt("unable to %s '%s': %s (%d)",
|
||||
request.verb(), request.uri, curl_easy_strerror(code), code));
|
||||
|
||||
|
@ -662,7 +662,7 @@ struct curlDataTransfer : public DataTransfer
|
|||
auto s3Res = s3Helper.getObject(bucketName, key);
|
||||
DataTransferResult res;
|
||||
if (!s3Res.data)
|
||||
throw DownloadError(NotFound, fmt("S3 object '%s' does not exist", request.uri));
|
||||
throw DataTransferError(NotFound, fmt("S3 object '%s' does not exist", request.uri));
|
||||
res.data = s3Res.data;
|
||||
callback(std::move(res));
|
||||
#else
|
||||
|
|
|
@ -72,7 +72,7 @@ struct DataTransfer
|
|||
virtual ~DataTransfer() { }
|
||||
|
||||
/* Enqueue a data transfer request, returning a future to the result of
|
||||
the download. The future may throw a DownloadError
|
||||
the download. The future may throw a DataTransferError
|
||||
exception. */
|
||||
virtual void enqueueDataTransfer(const DataTransferRequest & request,
|
||||
Callback<DataTransferResult> callback) = 0;
|
||||
|
@ -96,11 +96,11 @@ ref<DataTransfer> getDataTransfer();
|
|||
/* Return a new DataTransfer object. */
|
||||
ref<DataTransfer> makeDataTransfer();
|
||||
|
||||
class DownloadError : public Error
|
||||
class DataTransferError : public Error
|
||||
{
|
||||
public:
|
||||
DataTransfer::Error error;
|
||||
DownloadError(DataTransfer::Error error, const FormatOrString & fs)
|
||||
DataTransferError(DataTransfer::Error error, const FormatOrString & fs)
|
||||
: Error(fs), error(error)
|
||||
{ }
|
||||
};
|
||||
|
|
|
@ -89,7 +89,7 @@ protected:
|
|||
request.head = true;
|
||||
getDataTransfer()->download(request);
|
||||
return true;
|
||||
} catch (DownloadError & e) {
|
||||
} catch (DataTransferError & e) {
|
||||
/* S3 buckets return 403 if a file doesn't exist and the
|
||||
bucket is unlistable, so treat 403 as 404. */
|
||||
if (e.error == DataTransfer::NotFound || e.error == DataTransfer::Forbidden)
|
||||
|
@ -108,7 +108,7 @@ protected:
|
|||
req.mimeType = mimeType;
|
||||
try {
|
||||
getDataTransfer()->download(req);
|
||||
} catch (DownloadError & e) {
|
||||
} catch (DataTransferError & e) {
|
||||
throw UploadToHTTP("while uploading to HTTP binary cache at '%s': %s", cacheUri, e.msg());
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ protected:
|
|||
auto request(makeRequest(path));
|
||||
try {
|
||||
getDataTransfer()->download(std::move(request), sink);
|
||||
} catch (DownloadError & e) {
|
||||
} catch (DataTransferError & e) {
|
||||
if (e.error == DataTransfer::NotFound || e.error == DataTransfer::Forbidden)
|
||||
throw NoSuchBinaryCacheFile("file '%s' does not exist in binary cache '%s'", path, getUri());
|
||||
maybeDisable();
|
||||
|
@ -146,7 +146,7 @@ protected:
|
|||
{[callbackPtr, this](std::future<DataTransferResult> result) {
|
||||
try {
|
||||
(*callbackPtr)(result.get().data);
|
||||
} catch (DownloadError & e) {
|
||||
} catch (DataTransferError & e) {
|
||||
if (e.error == DataTransfer::NotFound || e.error == DataTransfer::Forbidden)
|
||||
return (*callbackPtr)(std::shared_ptr<std::string>());
|
||||
maybeDisable();
|
||||
|
|
|
@ -113,7 +113,7 @@ static void update(const StringSet & channelNames)
|
|||
// Download the channel tarball.
|
||||
try {
|
||||
filename = store->toRealPath(fetchers::downloadFile(store, url + "/nixexprs.tar.xz", "nixexprs.tar.xz", false).storePath);
|
||||
} catch (DownloadError & e) {
|
||||
} catch (DataTransferError & e) {
|
||||
filename = store->toRealPath(fetchers::downloadFile(store, url + "/nixexprs.tar.bz2", "nixexprs.tar.bz2", false).storePath);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue