util/Error: use std::exception_ptr instead of std::exception
Necessary to preserve type information. The try/catch sequence didn't
work previously.
Same fix as in commit 1c904000
This commit is contained in:
parent
c85ba73371
commit
d9e8ce22cb
@ -222,7 +222,7 @@ try {
|
||||
|
||||
return true;
|
||||
} catch (const std::exception &e) {
|
||||
error.Set(e);
|
||||
error.Set(std::current_exception());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,6 @@
|
||||
#include "Error.hxx"
|
||||
#include "Domain.hxx"
|
||||
|
||||
#include <exception>
|
||||
#include <system_error>
|
||||
|
||||
#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");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,15 +35,12 @@
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <exception>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user