aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-09-20 17:49:31 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-09-20 17:49:31 +0200
commitbeaefdf70648776cf83f80daf146eb774ff4c20c (patch)
tree192a97588aae0a99ec4ed806717eb0574e2d4f41
parentf12d56b27b9d8ed2411788f24af5b6dc63563568 (diff)
Tweak
-rw-r--r--src/libstore/download.cc6
-rw-r--r--src/libutil/util.cc4
-rw-r--r--src/libutil/util.hh3
3 files changed, 5 insertions, 8 deletions
diff --git a/src/libstore/download.cc b/src/libstore/download.cc
index 34cb8ed60..d7d0e29c0 100644
--- a/src/libstore/download.cc
+++ b/src/libstore/download.cc
@@ -98,11 +98,7 @@ struct CurlDownloader : public Downloader
{
assert(!done);
done = true;
- try {
- throw e;
- } catch (...) {
- callFailure(failure);
- }
+ callFailure(failure, std::make_exception_ptr(e));
}
size_t writeCallback(void * contents, size_t size, size_t nmemb)
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index c95a713fa..68311a3df 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -1230,10 +1230,10 @@ string base64Decode(const string & s)
}
-void callFailure(const std::function<void(std::exception_ptr exc)> & failure)
+void callFailure(const std::function<void(std::exception_ptr exc)> & failure, std::exception_ptr exc)
{
try {
- failure(std::current_exception());
+ failure(exc);
} catch (std::exception & e) {
printMsg(lvlError, format("uncaught exception: %s") % e.what());
abort();
diff --git a/src/libutil/util.hh b/src/libutil/util.hh
index 221165780..1a43bf400 100644
--- a/src/libutil/util.hh
+++ b/src/libutil/util.hh
@@ -383,7 +383,8 @@ string get(const T & map, const string & key, const string & def = "")
/* Call ‘failure’ with the current exception as argument. If ‘failure’
throws an exception, abort the program. */
-void callFailure(const std::function<void(std::exception_ptr exc)> & failure);
+void callFailure(const std::function<void(std::exception_ptr exc)> & failure,
+ std::exception_ptr exc = std::current_exception());
/* Evaluate the function ‘f’. If it returns a value, call ‘success’