mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-27 07:34:15 +02:00
Use throw_exception() instead of throw.
This commit is contained in:
parent
928804b5f3
commit
97a8869df1
@ -239,7 +239,7 @@ void ConfigObject::DumpObjects(const string& filename)
|
|||||||
fp.open(filename.c_str());
|
fp.open(filename.c_str());
|
||||||
|
|
||||||
if (!fp)
|
if (!fp)
|
||||||
throw runtime_error("Could not open retention.dat file");
|
throw_exception(runtime_error("Could not open retention.dat file"));
|
||||||
|
|
||||||
FIFO::Ptr fifo = boost::make_shared<FIFO>();
|
FIFO::Ptr fifo = boost::make_shared<FIFO>();
|
||||||
|
|
||||||
@ -298,7 +298,7 @@ void ConfigObject::RestoreObjects(const string& filename)
|
|||||||
Variant value = Variant::Deserialize(message);
|
Variant value = Variant::Deserialize(message);
|
||||||
|
|
||||||
if (!value.IsObjectType<Dictionary>())
|
if (!value.IsObjectType<Dictionary>())
|
||||||
throw runtime_error("JSON objects in the retention file must be dictionaries.");
|
throw_exception(runtime_error("JSON objects in the retention file must be dictionaries."));
|
||||||
|
|
||||||
Dictionary::Ptr persistentObject = value;
|
Dictionary::Ptr persistentObject = value;
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ Dictionary::Ptr Dictionary::FromJson(cJSON *json)
|
|||||||
Dictionary::Ptr dictionary = boost::make_shared<Dictionary>();
|
Dictionary::Ptr dictionary = boost::make_shared<Dictionary>();
|
||||||
|
|
||||||
if (json->type != cJSON_Object)
|
if (json->type != cJSON_Object)
|
||||||
throw invalid_argument("JSON type must be cJSON_Object.");
|
throw_exception(invalid_argument("JSON type must be cJSON_Object."));
|
||||||
|
|
||||||
for (cJSON *i = json->child; i != NULL; i = i->next) {
|
for (cJSON *i = json->child; i != NULL; i = i->next) {
|
||||||
dictionary->Set(i->string, Variant::FromJson(i));
|
dictionary->Set(i->string, Variant::FromJson(i));
|
||||||
@ -122,4 +122,4 @@ cJSON *Dictionary::ToJson(void) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ Variant Variant::FromJson(cJSON *json)
|
|||||||
else if (json->type == cJSON_NULL)
|
else if (json->type == cJSON_NULL)
|
||||||
return Variant();
|
return Variant();
|
||||||
else
|
else
|
||||||
throw invalid_argument("Unsupported JSON type.");
|
throw_exception(invalid_argument("Unsupported JSON type."));
|
||||||
}
|
}
|
||||||
|
|
||||||
string Variant::Serialize(void) const
|
string Variant::Serialize(void) const
|
||||||
@ -99,7 +99,7 @@ cJSON *Variant::ToJson(void) const
|
|||||||
} else if (m_Value.type() == typeid(boost::blank)) {
|
} else if (m_Value.type() == typeid(boost::blank)) {
|
||||||
return cJSON_CreateNull();
|
return cJSON_CreateNull();
|
||||||
} else {
|
} else {
|
||||||
throw runtime_error("Invalid variant type.");
|
throw_exception(runtime_error("Invalid variant type."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ void JsonRpcClient::DataAvailableHandler(void)
|
|||||||
Variant value = Variant::Deserialize(jsonString);
|
Variant value = Variant::Deserialize(jsonString);
|
||||||
|
|
||||||
if (!value.IsObjectType<Dictionary>())
|
if (!value.IsObjectType<Dictionary>())
|
||||||
throw invalid_argument("JSON-RPC message must be a dictionary.");
|
throw_exception(invalid_argument("JSON-RPC message must be a dictionary."));
|
||||||
|
|
||||||
OnNewMessage(GetSelf(), MessagePart(value));
|
OnNewMessage(GetSelf(), MessagePart(value));
|
||||||
} catch (const exception& ex) {
|
} catch (const exception& ex) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user