Throw saved exception in JSON decoder

refs #7452
This commit is contained in:
Gunnar Beutner 2014-10-27 09:28:32 +01:00
parent f05ccd07f9
commit 8b339a6cd5
1 changed files with 6 additions and 2 deletions

View File

@ -177,7 +177,8 @@ public:
void ThrowException(void) const
{
boost::rethrow_exception(m_Exception);
if (m_Exception)
boost::rethrow_exception(m_Exception);
}
private:
@ -234,7 +235,7 @@ static int DecodeString(void *ctx, const unsigned char *str, size_t len)
JsonContext *context = static_cast<JsonContext *>(ctx);
try {
context->AddValue(String(reinterpret_cast<const char *>(str), reinterpret_cast<const char *>(str) + len));
context->AddValue(String(str, str + len));
} catch (...) {
context->SaveException();
return 0;
@ -329,6 +330,9 @@ Value icinga::JsonDecode(const String& data)
yajl_free(handle);
/* throw saved exception (if there is one) */
context.ThrowException();
BOOST_THROW_EXCEPTION(std::invalid_argument(msg));
}