diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-03-22 18:26:20 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-03-22 18:26:20 (GMT) |
commit | c7f8f82d632f3d205ef6de6377115ea0f7536302 (patch) | |
tree | e9b3246ac897f31293a8592ac836562f6e454d00 /src | |
parent | aed71bb1cc4209156f132b34041982521bf78025 (diff) | |
download | uscxml-c7f8f82d632f3d205ef6de6377115ea0f7536302.zip uscxml-c7f8f82d632f3d205ef6de6377115ea0f7536302.tar.gz uscxml-c7f8f82d632f3d205ef6de6377115ea0f7536302.tar.bz2 |
Use actual curl message for errors regarding URLs
Diffstat (limited to 'src')
-rw-r--r-- | src/uscxml/Interpreter.cpp | 3 | ||||
-rw-r--r-- | src/uscxml/URL.cpp | 10 | ||||
-rw-r--r-- | src/uscxml/URL.h | 12 |
3 files changed, 18 insertions, 7 deletions
diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp index d5c8b7f..0c466c9 100644 --- a/src/uscxml/Interpreter.cpp +++ b/src/uscxml/Interpreter.cpp @@ -87,6 +87,9 @@ Interpreter* Interpreter::fromURI(const std::string& uri) { // use curl for everything else std::stringstream ss; ss << absUrl; + if (absUrl.downloadFailed()) { + return NULL; + } ss.seekg(0); inputSource.setByteStream(ss); } diff --git a/src/uscxml/URL.cpp b/src/uscxml/URL.cpp index 7036e0a..a31b0c4 100644 --- a/src/uscxml/URL.cpp +++ b/src/uscxml/URL.cpp @@ -106,10 +106,10 @@ void URLImpl::downloadCompleted() { } } -void URLImpl::downloadFailed(int errorCode) { +void URLImpl::downloadFailed(CURLcode errorCode) { tthread::lock_guard<tthread::recursive_mutex> lock(_mutex); - LOG(ERROR) << "Downloading " << asString() << " failed: " << strerror(errorCode); + LOG(ERROR) << "Downloading " << asString() << " failed: " << curl_easy_strerror(errorCode); _hasFailed = true; _isDownloaded = false; @@ -392,7 +392,7 @@ void URLFetcher::breakURL(URL& url) { tthread::lock_guard<tthread::recursive_mutex> lock(instance->_mutex); if (instance->_handlesToURLs.find(handle) != instance->_handlesToURLs.end()) { - url.downloadFailed(0); + url.downloadFailed(CURLE_OK); curl_multi_remove_handle(instance->_multiHandle, handle); instance->_handlesToURLs.erase(handle); } @@ -496,6 +496,8 @@ void URLFetcher::perform() { curl_multi_remove_handle(_multiHandle, msg->easy_handle); _handlesToURLs.erase(msg->easy_handle); break; + default: + LOG(ERROR) << "Unhandled curl status"; case CURLM_BAD_HANDLE: case CURLM_BAD_EASY_HANDLE: case CURLM_OUT_OF_MEMORY: @@ -506,8 +508,6 @@ void URLFetcher::perform() { _handlesToURLs[msg->easy_handle].downloadFailed(msg->data.result); curl_multi_remove_handle(_multiHandle, msg->easy_handle); _handlesToURLs.erase(msg->easy_handle); - default: - LOG(ERROR) << "Unhandled curl status"; break; } } else { diff --git a/src/uscxml/URL.h b/src/uscxml/URL.h index 0e47607..61a225c 100644 --- a/src/uscxml/URL.h +++ b/src/uscxml/URL.h @@ -83,7 +83,11 @@ public: void downloadStarted(); void downloadCompleted(); - void downloadFailed(int errorCode); + void downloadFailed(CURLcode errorCode); + + bool downloadFailed() { + return _hasFailed; + } friend class URLFetcher; @@ -186,6 +190,10 @@ public: _impl->removeMonitor(monitor); } + bool downloadFailed() { + return _impl->downloadFailed(); + } + const bool isAbsolute() const { return _impl->isAbsolute(); } @@ -218,7 +226,7 @@ protected: void downloadCompleted() { return _impl->downloadCompleted(); } - void downloadFailed(int errorCode) { + void downloadFailed(CURLcode errorCode) { return _impl->downloadFailed(errorCode); } |