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;
|
return true;
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
error.Set(e);
|
error.Set(std::current_exception());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ try {
|
|||||||
std::move(reader), info.GetSize(),
|
std::move(reader), info.GetSize(),
|
||||||
mutex, cond);
|
mutex, cond);
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
error.Set(e);
|
error.Set(std::current_exception());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ try {
|
|||||||
offset = new_offset;
|
offset = new_offset;
|
||||||
return true;
|
return true;
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
error.Set(e);
|
error.Set(std::current_exception());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ try {
|
|||||||
offset += nbytes;
|
offset += nbytes;
|
||||||
return nbytes;
|
return nbytes;
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
error.Set(e);
|
error.Set(std::current_exception());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
#include "Error.hxx"
|
#include "Error.hxx"
|
||||||
#include "Domain.hxx"
|
#include "Domain.hxx"
|
||||||
|
|
||||||
#include <exception>
|
|
||||||
#include <system_error>
|
#include <system_error>
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
@ -54,11 +53,11 @@ const Domain win32_domain("win32");
|
|||||||
Error::~Error() {}
|
Error::~Error() {}
|
||||||
|
|
||||||
void
|
void
|
||||||
Error::Set(const std::exception &src)
|
Error::Set(std::exception_ptr src)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
/* classify the exception */
|
/* classify the exception */
|
||||||
throw src;
|
std::rethrow_exception(src);
|
||||||
} catch (const std::system_error &se) {
|
} catch (const std::system_error &se) {
|
||||||
if (se.code().category() == std::system_category()) {
|
if (se.code().category() == std::system_category()) {
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
@ -67,9 +66,11 @@ Error::Set(const std::exception &src)
|
|||||||
Set(errno_domain, se.code().value(), se.what());
|
Set(errno_domain, se.code().value(), se.what());
|
||||||
#endif
|
#endif
|
||||||
} else
|
} else
|
||||||
Set(exception_domain, src.what());
|
Set(exception_domain, se.what());
|
||||||
|
} catch (const std::exception &e) {
|
||||||
|
Set(exception_domain, e.what());
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
Set(exception_domain, src.what());
|
Set(exception_domain, "Unknown exception");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,15 +35,12 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
class Domain;
|
class Domain;
|
||||||
|
|
||||||
namespace std {
|
|
||||||
class exception;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Domain for std::exception */
|
/** Domain for std::exception */
|
||||||
extern const Domain exception_domain;
|
extern const Domain exception_domain;
|
||||||
|
|
||||||
@ -133,7 +130,7 @@ public:
|
|||||||
message = other.message;
|
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);
|
void Set(const Domain &_domain, int _code, const char *_message);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user