diff --git a/src/db/plugins/simple/SimpleDatabasePlugin.cxx b/src/db/plugins/simple/SimpleDatabasePlugin.cxx index 78f783f67..13168147a 100644 --- a/src/db/plugins/simple/SimpleDatabasePlugin.cxx +++ b/src/db/plugins/simple/SimpleDatabasePlugin.cxx @@ -222,7 +222,7 @@ try { return true; } catch (const std::exception &e) { - error.Set(e); + error.Set(std::current_exception()); return false; } diff --git a/src/input/plugins/FileInputPlugin.cxx b/src/input/plugins/FileInputPlugin.cxx index 65fc830dd..2997bc3e0 100644 --- a/src/input/plugins/FileInputPlugin.cxx +++ b/src/input/plugins/FileInputPlugin.cxx @@ -81,7 +81,7 @@ try { std::move(reader), info.GetSize(), mutex, cond); } catch (const std::exception &e) { - error.Set(e); + error.Set(std::current_exception()); return nullptr; } @@ -102,7 +102,7 @@ try { offset = new_offset; return true; } catch (const std::exception &e) { - error.Set(e); + error.Set(std::current_exception()); return false; } @@ -113,7 +113,7 @@ try { offset += nbytes; return nbytes; } catch (const std::exception &e) { - error.Set(e); + error.Set(std::current_exception()); return 0; } diff --git a/src/util/Error.cxx b/src/util/Error.cxx index d6f4c1595..4fc067636 100644 --- a/src/util/Error.cxx +++ b/src/util/Error.cxx @@ -31,7 +31,6 @@ #include "Error.hxx" #include "Domain.hxx" -#include #include #ifdef WIN32 @@ -54,11 +53,11 @@ const Domain win32_domain("win32"); Error::~Error() {} void -Error::Set(const std::exception &src) +Error::Set(std::exception_ptr src) { try { /* classify the exception */ - throw src; + std::rethrow_exception(src); } catch (const std::system_error &se) { if (se.code().category() == std::system_category()) { #ifdef WIN32 @@ -67,9 +66,11 @@ Error::Set(const std::exception &src) Set(errno_domain, se.code().value(), se.what()); #endif } else - Set(exception_domain, src.what()); + Set(exception_domain, se.what()); + } catch (const std::exception &e) { + Set(exception_domain, e.what()); } catch (...) { - Set(exception_domain, src.what()); + Set(exception_domain, "Unknown exception"); } } diff --git a/src/util/Error.hxx b/src/util/Error.hxx index b86cb3918..0b678c8d9 100644 --- a/src/util/Error.hxx +++ b/src/util/Error.hxx @@ -35,15 +35,12 @@ #include #include +#include #include class Domain; -namespace std { - class exception; -} - /** Domain for std::exception */ extern const Domain exception_domain; @@ -133,7 +130,7 @@ public: message = other.message; } - void Set(const std::exception &src); + void Set(std::exception_ptr src); void Set(const Domain &_domain, int _code, const char *_message);