Package Kit: map some curl errors to Be error codes

Trying to get something more useful than "aborted: no error" in case of
network errors in pkgman.
This commit is contained in:
Adrien Destugues 2017-10-07 22:05:47 +02:00
parent 1f424b6ac8
commit a00bd28a9b

View File

@ -120,11 +120,41 @@ FetchFileJob::Execute()
result = curl_easy_perform(handle); result = curl_easy_perform(handle);
curl_easy_cleanup(handle); curl_easy_cleanup(handle);
if (result != CURLE_OK) {
switch (result) {
case CURLE_OK:
return B_OK;
case CURLE_UNSUPPORTED_PROTOCOL:
return EPROTONOSUPPORT;
case CURLE_FAILED_INIT:
return B_NO_INIT;
case CURLE_URL_MALFORMAT:
return B_BAD_VALUE;
case CURLE_NOT_BUILT_IN:
return B_NOT_SUPPORTED;
case CURLE_COULDNT_RESOLVE_PROXY:
case CURLE_COULDNT_RESOLVE_HOST:
return B_NAME_NOT_FOUND;
case CURLE_COULDNT_CONNECT:
return ECONNREFUSED;
case CURLE_FTP_WEIRD_SERVER_REPLY:
return B_BAD_DATA;
case CURLE_REMOTE_ACCESS_DENIED:
return B_NOT_ALLOWED;
case CURLE_PARTIAL_FILE:
return B_PARTIAL_READ;
case CURLE_OUT_OF_MEMORY:
return B_NO_MEMORY;
case CURLE_OPERATION_TIMEDOUT:
return B_TIMED_OUT;
case CURLE_SSL_CONNECT_ERROR:
return B_BAD_REPLY;
default:
// TODO: map more curl error codes to ours for more // TODO: map more curl error codes to ours for more
// precise error reporting // precise error reporting
return B_ERROR; return B_ERROR;
} }
#endif /* !HAIKU_BOOTSTRAP_BUILD */ #endif /* !HAIKU_BOOTSTRAP_BUILD */
return B_OK; return B_OK;