summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-03-22 18:26:20 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-03-22 18:26:20 (GMT)
commitc7f8f82d632f3d205ef6de6377115ea0f7536302 (patch)
treee9b3246ac897f31293a8592ac836562f6e454d00
parentaed71bb1cc4209156f132b34041982521bf78025 (diff)
downloaduscxml-c7f8f82d632f3d205ef6de6377115ea0f7536302.zip
uscxml-c7f8f82d632f3d205ef6de6377115ea0f7536302.tar.gz
uscxml-c7f8f82d632f3d205ef6de6377115ea0f7536302.tar.bz2
Use actual curl message for errors regarding URLs
-rw-r--r--src/uscxml/Interpreter.cpp3
-rw-r--r--src/uscxml/URL.cpp10
-rw-r--r--src/uscxml/URL.h12
-rw-r--r--test/src/test-url.cpp1
4 files changed, 19 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);
}
diff --git a/test/src/test-url.cpp b/test/src/test-url.cpp
index 7b72250..f2d0cb9 100644
--- a/test/src/test-url.cpp
+++ b/test/src/test-url.cpp
@@ -26,6 +26,7 @@ int main(int argc, char** argv) {
{
Interpreter* interpreter = Interpreter::fromURI("https://raw.github.com/tklab-tud/uscxml/master/test/samples/uscxml/test-execution.scxml");
+ assert(interpreter);
interpreter->interpret();
delete interpreter;
}