mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-11-30 23:49:05 +08:00
Merge pull request #2894 from stweil/curl
Report errors from curl_easy functions
This commit is contained in:
commit
6e307074d8
@ -1148,14 +1148,28 @@ bool TessBaseAPI::ProcessPagesInternal(const char* filename,
|
||||
return false;
|
||||
} else {
|
||||
CURLcode curlcode;
|
||||
auto error = [curl, curlcode](const char* function) {
|
||||
fprintf(stderr, "Error, %s failed with error %s\n", function,
|
||||
curl_easy_strerror(curlcode));
|
||||
curl_easy_cleanup(curl);
|
||||
return false;
|
||||
};
|
||||
curlcode = curl_easy_setopt(curl, CURLOPT_URL, filename);
|
||||
ASSERT_HOST(curlcode == CURLE_OK);
|
||||
if (curlcode != CURLE_OK) {
|
||||
return error("curl_easy_setopt");
|
||||
}
|
||||
curlcode = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
|
||||
ASSERT_HOST(curlcode == CURLE_OK);
|
||||
if (curlcode != CURLE_OK) {
|
||||
return error("curl_easy_setopt");
|
||||
}
|
||||
curlcode = curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buf);
|
||||
ASSERT_HOST(curlcode == CURLE_OK);
|
||||
if (curlcode != CURLE_OK) {
|
||||
return error("curl_easy_setopt");
|
||||
}
|
||||
curlcode = curl_easy_perform(curl);
|
||||
ASSERT_HOST(curlcode == CURLE_OK);
|
||||
if (curlcode != CURLE_OK) {
|
||||
return error("curl_easy_perform");
|
||||
}
|
||||
curl_easy_cleanup(curl);
|
||||
data = reinterpret_cast<const l_uint8 *>(buf.data());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user