mirror of https://github.com/Icinga/icinga2.git
Use BOOST_THROW_EXCEPTION instead of boost::throw_exception()
Fixes #3636
This commit is contained in:
parent
e047e06fc8
commit
b887f14d96
|
@ -108,7 +108,7 @@ void CheckerComponent::CheckTimerHandler(void)
|
||||||
try {
|
try {
|
||||||
service->BeginExecuteCheck(boost::bind(&CheckerComponent::CheckCompletedHandler, this, service));
|
service->BeginExecuteCheck(boost::bind(&CheckerComponent::CheckCompletedHandler, this, service));
|
||||||
} catch (const exception& ex) {
|
} catch (const exception& ex) {
|
||||||
Logger::Write(LogCritical, "checker", "Exception occured while checking service '" + service->GetName() + "': " + ex.what());
|
Logger::Write(LogCritical, "checker", "Exception occured while checking service '" + service->GetName() + "': " + diagnostic_information(ex));
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks++;
|
tasks++;
|
||||||
|
|
|
@ -104,25 +104,25 @@ void CompatComponent::CommandPipeThread(const String& commandPath)
|
||||||
fifo_ok = true;
|
fifo_ok = true;
|
||||||
} else {
|
} else {
|
||||||
if (unlink(commandPath.CStr()) < 0)
|
if (unlink(commandPath.CStr()) < 0)
|
||||||
throw_exception(PosixException("unlink() failed", errno));
|
BOOST_THROW_EXCEPTION(PosixException("unlink() failed", errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!fifo_ok && mkfifo(commandPath.CStr(), S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) < 0)
|
if (!fifo_ok && mkfifo(commandPath.CStr(), S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) < 0)
|
||||||
throw_exception(PosixException("mkfifo() failed", errno));
|
BOOST_THROW_EXCEPTION(PosixException("mkfifo() failed", errno));
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int fd = open(commandPath.CStr(), O_RDONLY);
|
int fd = open(commandPath.CStr(), O_RDONLY);
|
||||||
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
throw_exception(PosixException("open() failed", errno));
|
BOOST_THROW_EXCEPTION(PosixException("open() failed", errno));
|
||||||
|
|
||||||
FILE *fp = fdopen(fd, "r");
|
FILE *fp = fdopen(fd, "r");
|
||||||
|
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
close(fd);
|
close(fd);
|
||||||
throw_exception(PosixException("fdopen() failed", errno));
|
BOOST_THROW_EXCEPTION(PosixException("fdopen() failed", errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
char line[2048];
|
char line[2048];
|
||||||
|
@ -149,7 +149,7 @@ void CompatComponent::ProcessCommand(const String& command)
|
||||||
ExternalCommandProcessor::Execute(command);
|
ExternalCommandProcessor::Execute(command);
|
||||||
} catch (const exception& ex) {
|
} catch (const exception& ex) {
|
||||||
stringstream msgbuf;
|
stringstream msgbuf;
|
||||||
msgbuf << "External command failed: " << ex.what();
|
msgbuf << "External command failed: " << diagnostic_information(ex);
|
||||||
Logger::Write(LogWarning, "compat", msgbuf.str());
|
Logger::Write(LogWarning, "compat", msgbuf.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -503,11 +503,11 @@ void CompatComponent::StatusTimerHandler(void)
|
||||||
|
|
||||||
statusfp.close();
|
statusfp.close();
|
||||||
if (rename(statuspathtmp.CStr(), statuspath.CStr()) < 0)
|
if (rename(statuspathtmp.CStr(), statuspath.CStr()) < 0)
|
||||||
throw_exception(PosixException("rename() failed", errno));
|
BOOST_THROW_EXCEPTION(PosixException("rename() failed", errno));
|
||||||
|
|
||||||
objectfp.close();
|
objectfp.close();
|
||||||
if (rename(objectspathtmp.CStr(), objectspath.CStr()) < 0)
|
if (rename(objectspathtmp.CStr(), objectspath.CStr()) < 0)
|
||||||
throw_exception(PosixException("rename() failed", errno));
|
BOOST_THROW_EXCEPTION(PosixException("rename() failed", errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_COMPONENT(compat, CompatComponent);
|
EXPORT_COMPONENT(compat, CompatComponent);
|
||||||
|
|
|
@ -217,7 +217,7 @@ void ReplicationComponent::RemoteObjectUpdateHandler(const RequestMessage& reque
|
||||||
object->Register();
|
object->Register();
|
||||||
} else {
|
} else {
|
||||||
if (object->IsLocal())
|
if (object->IsLocal())
|
||||||
throw_exception(invalid_argument("Replicated remote object is marked as local."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Replicated remote object is marked as local."));
|
||||||
|
|
||||||
// TODO: disallow config updates depending on endpoint config
|
// TODO: disallow config updates depending on endpoint config
|
||||||
|
|
||||||
|
|
|
@ -255,7 +255,7 @@ int main(int argc, char **argv)
|
||||||
Application::Ptr app = Application::GetInstance();
|
Application::Ptr app = Application::GetInstance();
|
||||||
|
|
||||||
if (!app)
|
if (!app)
|
||||||
throw_exception(runtime_error("Configuration must create an Application object."));
|
BOOST_THROW_EXCEPTION(runtime_error("Configuration must create an Application object."));
|
||||||
|
|
||||||
if (g_AppParams.count("daemonize")) {
|
if (g_AppParams.count("daemonize")) {
|
||||||
Logger::Write(LogInformation, "icinga", "Daemonizing.");
|
Logger::Write(LogInformation, "icinga", "Daemonizing.");
|
||||||
|
|
|
@ -37,7 +37,7 @@ Application::Application(const Dictionary::Ptr& serializedUpdate)
|
||||||
: DynamicObject(serializedUpdate), m_PidFile(NULL)
|
: DynamicObject(serializedUpdate), m_PidFile(NULL)
|
||||||
{
|
{
|
||||||
if (!IsLocal())
|
if (!IsLocal())
|
||||||
throw_exception(runtime_error("Application objects must be local."));
|
BOOST_THROW_EXCEPTION(runtime_error("Application objects must be local."));
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
/* disable GUI-based error messages for LoadLibrary() */
|
/* disable GUI-based error messages for LoadLibrary() */
|
||||||
|
@ -45,7 +45,7 @@ Application::Application(const Dictionary::Ptr& serializedUpdate)
|
||||||
|
|
||||||
WSADATA wsaData;
|
WSADATA wsaData;
|
||||||
if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0)
|
if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0)
|
||||||
throw_exception(Win32Exception("WSAStartup failed", WSAGetLastError()));
|
BOOST_THROW_EXCEPTION(Win32Exception("WSAStartup failed", WSAGetLastError()));
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
char *debugging = getenv("_DEBUG");
|
char *debugging = getenv("_DEBUG");
|
||||||
|
@ -205,7 +205,7 @@ String Application::GetExePath(const String& argv0)
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
char buffer[MAXPATHLEN];
|
char buffer[MAXPATHLEN];
|
||||||
if (getcwd(buffer, sizeof(buffer)) == NULL)
|
if (getcwd(buffer, sizeof(buffer)) == NULL)
|
||||||
throw_exception(PosixException("getcwd failed", errno));
|
BOOST_THROW_EXCEPTION(PosixException("getcwd failed", errno));
|
||||||
String workingDirectory = buffer;
|
String workingDirectory = buffer;
|
||||||
|
|
||||||
if (argv0[0] != '/')
|
if (argv0[0] != '/')
|
||||||
|
@ -240,20 +240,20 @@ String Application::GetExePath(const String& argv0)
|
||||||
|
|
||||||
if (!foundPath) {
|
if (!foundPath) {
|
||||||
executablePath.Clear();
|
executablePath.Clear();
|
||||||
throw_exception(runtime_error("Could not determine executable path."));
|
BOOST_THROW_EXCEPTION(runtime_error("Could not determine executable path."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (realpath(executablePath.CStr(), buffer) == NULL)
|
if (realpath(executablePath.CStr(), buffer) == NULL)
|
||||||
throw_exception(PosixException("realpath failed", errno));
|
BOOST_THROW_EXCEPTION(PosixException("realpath failed", errno));
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
#else /* _WIN32 */
|
#else /* _WIN32 */
|
||||||
char FullExePath[MAXPATHLEN];
|
char FullExePath[MAXPATHLEN];
|
||||||
|
|
||||||
if (!GetModuleFileName(NULL, FullExePath, sizeof(FullExePath)))
|
if (!GetModuleFileName(NULL, FullExePath, sizeof(FullExePath)))
|
||||||
throw_exception(Win32Exception("GetModuleFileName() failed", GetLastError()));
|
BOOST_THROW_EXCEPTION(Win32Exception("GetModuleFileName() failed", GetLastError()));
|
||||||
|
|
||||||
return FullExePath;
|
return FullExePath;
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
@ -375,12 +375,8 @@ void Application::ExceptionHandler(void)
|
||||||
try {
|
try {
|
||||||
throw;
|
throw;
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl
|
||||||
std::cerr << "Unhandled exception of type "
|
<< diagnostic_information(ex)
|
||||||
<< Utility::GetTypeName(typeid(ex))
|
|
||||||
<< std::endl;
|
|
||||||
std::cerr << "Diagnostic Information: "
|
|
||||||
<< ex.what()
|
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -460,7 +456,7 @@ void Application::UpdatePidFile(const String& filename)
|
||||||
m_PidFile = fopen(filename.CStr(), "w");
|
m_PidFile = fopen(filename.CStr(), "w");
|
||||||
|
|
||||||
if (m_PidFile == NULL)
|
if (m_PidFile == NULL)
|
||||||
throw_exception(runtime_error("Could not open PID file '" + filename + "'"));
|
BOOST_THROW_EXCEPTION(runtime_error("Could not open PID file '" + filename + "'"));
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
if (flock(fileno(m_PidFile), LOCK_EX | LOCK_NB) < 0) {
|
if (flock(fileno(m_PidFile), LOCK_EX | LOCK_NB) < 0) {
|
||||||
|
|
|
@ -91,10 +91,10 @@ public:
|
||||||
TResult GetResult(void)
|
TResult GetResult(void)
|
||||||
{
|
{
|
||||||
if (!m_Finished)
|
if (!m_Finished)
|
||||||
throw_exception(runtime_error("GetResult called on an unfinished AsyncTask"));
|
BOOST_THROW_EXCEPTION(runtime_error("GetResult called on an unfinished AsyncTask"));
|
||||||
|
|
||||||
if (m_ResultRetrieved)
|
if (m_ResultRetrieved)
|
||||||
throw_exception(runtime_error("GetResult called on an AsyncTask whose result was already retrieved."));
|
BOOST_THROW_EXCEPTION(runtime_error("GetResult called on an AsyncTask whose result was already retrieved."));
|
||||||
|
|
||||||
m_ResultRetrieved = true;
|
m_ResultRetrieved = true;
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ Component::Component(const Dictionary::Ptr& properties)
|
||||||
assert(Application::IsMainThread());
|
assert(Application::IsMainThread());
|
||||||
|
|
||||||
if (!IsLocal())
|
if (!IsLocal())
|
||||||
throw_exception(runtime_error("Component objects must be local."));
|
BOOST_THROW_EXCEPTION(runtime_error("Component objects must be local."));
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
HMODULE
|
HMODULE
|
||||||
|
@ -63,14 +63,14 @@ Component::Component(const Dictionary::Ptr& properties)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (pCreateComponent == NULL)
|
if (pCreateComponent == NULL)
|
||||||
throw_exception(runtime_error("Loadable module does not contain "
|
BOOST_THROW_EXCEPTION(runtime_error("Loadable module does not contain "
|
||||||
"CreateComponent function"));
|
"CreateComponent function"));
|
||||||
|
|
||||||
/* pCreateComponent returns a raw pointer which we must wrap in a shared_ptr */
|
/* pCreateComponent returns a raw pointer which we must wrap in a shared_ptr */
|
||||||
impl = IComponent::Ptr(pCreateComponent());
|
impl = IComponent::Ptr(pCreateComponent());
|
||||||
|
|
||||||
if (!impl)
|
if (!impl)
|
||||||
throw_exception(runtime_error("CreateComponent function returned NULL."));
|
BOOST_THROW_EXCEPTION(runtime_error("CreateComponent function returned NULL."));
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
FreeLibrary(hModule);
|
FreeLibrary(hModule);
|
||||||
|
|
|
@ -223,7 +223,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_exception(invalid_argument("JSON type must be cJSON_Object."));
|
BOOST_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, Value::FromJson(i));
|
dictionary->Set(i->string, Value::FromJson(i));
|
||||||
|
|
|
@ -39,7 +39,7 @@ DynamicObject::DynamicObject(const Dictionary::Ptr& serializedObject)
|
||||||
RegisterAttribute("methods", Attribute_Config);
|
RegisterAttribute("methods", Attribute_Config);
|
||||||
|
|
||||||
if (!serializedObject->Contains("configTx"))
|
if (!serializedObject->Contains("configTx"))
|
||||||
throw_exception(invalid_argument("Serialized object must contain a config snapshot."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Serialized object must contain a config snapshot."));
|
||||||
|
|
||||||
/* apply config state from the config item/remote update;
|
/* apply config state from the config item/remote update;
|
||||||
* The DynamicObject::Create function takes care of restoring
|
* The DynamicObject::Create function takes care of restoring
|
||||||
|
@ -173,7 +173,7 @@ void DynamicObject::InternalSetAttribute(const String& name, const Value& data,
|
||||||
Value oldValue;
|
Value oldValue;
|
||||||
|
|
||||||
if (!allowEditConfig && (tt.first->second.Type & Attribute_Config))
|
if (!allowEditConfig && (tt.first->second.Type & Attribute_Config))
|
||||||
throw_exception(runtime_error("Config properties are immutable: '" + name + "'."));
|
BOOST_THROW_EXCEPTION(runtime_error("Config properties are immutable: '" + name + "'."));
|
||||||
|
|
||||||
if (!tt.second && tx >= tt.first->second.Tx) {
|
if (!tt.second && tx >= tt.first->second.Tx) {
|
||||||
oldValue = tt.first->second.Data;
|
oldValue = tt.first->second.Data;
|
||||||
|
@ -312,7 +312,7 @@ ScriptTask::Ptr DynamicObject::InvokeMethod(const String& method,
|
||||||
ScriptFunction::Ptr func = ScriptFunction::GetByName(funcName);
|
ScriptFunction::Ptr func = ScriptFunction::GetByName(funcName);
|
||||||
|
|
||||||
if (!func)
|
if (!func)
|
||||||
throw_exception(invalid_argument("Function '" + funcName + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Function '" + funcName + "' does not exist."));
|
||||||
|
|
||||||
ScriptTask::Ptr task = boost::make_shared<ScriptTask>(func, arguments);
|
ScriptTask::Ptr task = boost::make_shared<ScriptTask>(func, arguments);
|
||||||
task->Start(callback);
|
task->Start(callback);
|
||||||
|
@ -330,7 +330,7 @@ void DynamicObject::DumpObjects(const String& filename)
|
||||||
fp.open(tempFilename.CStr(), std::ios_base::out);
|
fp.open(tempFilename.CStr(), std::ios_base::out);
|
||||||
|
|
||||||
if (!fp)
|
if (!fp)
|
||||||
throw_exception(runtime_error("Could not open '" + filename + "' file"));
|
BOOST_THROW_EXCEPTION(runtime_error("Could not open '" + filename + "' file"));
|
||||||
|
|
||||||
StdioStream::Ptr sfp = boost::make_shared<StdioStream>(&fp, false);
|
StdioStream::Ptr sfp = boost::make_shared<StdioStream>(&fp, false);
|
||||||
sfp->Start();
|
sfp->Start();
|
||||||
|
@ -377,7 +377,7 @@ void DynamicObject::DumpObjects(const String& filename)
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
if (rename(tempFilename.CStr(), filename.CStr()) < 0)
|
if (rename(tempFilename.CStr(), filename.CStr()) < 0)
|
||||||
throw_exception(PosixException("rename() failed", errno));
|
BOOST_THROW_EXCEPTION(PosixException("rename() failed", errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicObject::RestoreObjects(const String& filename)
|
void DynamicObject::RestoreObjects(const String& filename)
|
||||||
|
@ -405,7 +405,7 @@ void DynamicObject::RestoreObjects(const String& filename)
|
||||||
DynamicType::Ptr dt = DynamicType::GetByName(type);
|
DynamicType::Ptr dt = DynamicType::GetByName(type);
|
||||||
|
|
||||||
if (!dt)
|
if (!dt)
|
||||||
throw_exception(invalid_argument("Invalid type: " + type));
|
BOOST_THROW_EXCEPTION(invalid_argument("Invalid type: " + type));
|
||||||
|
|
||||||
DynamicObject::Ptr object = dt->GetObject(name);
|
DynamicObject::Ptr object = dt->GetObject(name);
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ DynamicObject::Ptr DynamicType::GetObject(const String& name) const
|
||||||
void DynamicType::RegisterType(const DynamicType::Ptr& type)
|
void DynamicType::RegisterType(const DynamicType::Ptr& type)
|
||||||
{
|
{
|
||||||
if (GetByName(type->GetName()))
|
if (GetByName(type->GetName()))
|
||||||
throw_exception(runtime_error("Cannot register class for type '" +
|
BOOST_THROW_EXCEPTION(runtime_error("Cannot register class for type '" +
|
||||||
type->GetName() + "': Objects of this type already exist."));
|
type->GetName() + "': Objects of this type already exist."));
|
||||||
|
|
||||||
GetTypes()[type->GetName()] = type;
|
GetTypes()[type->GetName()] = type;
|
||||||
|
|
|
@ -60,7 +60,7 @@ void FIFO::ResizeBuffer(size_t newSize)
|
||||||
char *newBuffer = static_cast<char *>(realloc(m_Buffer, newSize));
|
char *newBuffer = static_cast<char *>(realloc(m_Buffer, newSize));
|
||||||
|
|
||||||
if (newBuffer == NULL)
|
if (newBuffer == NULL)
|
||||||
throw_exception(bad_alloc());
|
BOOST_THROW_EXCEPTION(bad_alloc());
|
||||||
|
|
||||||
m_Buffer = newBuffer;
|
m_Buffer = newBuffer;
|
||||||
|
|
||||||
|
|
|
@ -138,6 +138,7 @@ using std::type_info;
|
||||||
#include <boost/uuid/uuid_generators.hpp>
|
#include <boost/uuid/uuid_generators.hpp>
|
||||||
#include <boost/uuid/uuid_io.hpp>
|
#include <boost/uuid/uuid_io.hpp>
|
||||||
#include <boost/program_options.hpp>
|
#include <boost/program_options.hpp>
|
||||||
|
#include <boost/exception/diagnostic_information.hpp>
|
||||||
|
|
||||||
using boost::shared_ptr;
|
using boost::shared_ptr;
|
||||||
using boost::weak_ptr;
|
using boost::weak_ptr;
|
||||||
|
@ -151,9 +152,9 @@ using boost::condition_variable;
|
||||||
using boost::system_time;
|
using boost::system_time;
|
||||||
using boost::posix_time::millisec;
|
using boost::posix_time::millisec;
|
||||||
using boost::tie;
|
using boost::tie;
|
||||||
using boost::throw_exception;
|
|
||||||
using boost::rethrow_exception;
|
using boost::rethrow_exception;
|
||||||
using boost::current_exception;
|
using boost::current_exception;
|
||||||
|
using boost::diagnostic_information;
|
||||||
|
|
||||||
namespace tuples = boost::tuples;
|
namespace tuples = boost::tuples;
|
||||||
|
|
||||||
|
|
|
@ -32,11 +32,11 @@ Logger::Logger(const Dictionary::Ptr& properties)
|
||||||
: DynamicObject(properties)
|
: DynamicObject(properties)
|
||||||
{
|
{
|
||||||
if (!IsLocal())
|
if (!IsLocal())
|
||||||
throw_exception(runtime_error("Logger objects must be local."));
|
BOOST_THROW_EXCEPTION(runtime_error("Logger objects must be local."));
|
||||||
|
|
||||||
String type = Get("type");
|
String type = Get("type");
|
||||||
if (type.IsEmpty())
|
if (type.IsEmpty())
|
||||||
throw_exception(runtime_error("Logger objects must have a 'type' property."));
|
BOOST_THROW_EXCEPTION(runtime_error("Logger objects must have a 'type' property."));
|
||||||
|
|
||||||
ILogger::Ptr impl;
|
ILogger::Ptr impl;
|
||||||
|
|
||||||
|
@ -44,12 +44,12 @@ Logger::Logger(const Dictionary::Ptr& properties)
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
impl = boost::make_shared<SyslogLogger>();
|
impl = boost::make_shared<SyslogLogger>();
|
||||||
#else /* _WIN32 */
|
#else /* _WIN32 */
|
||||||
throw_exception(invalid_argument("Syslog is not supported on Windows."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Syslog is not supported on Windows."));
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
} else if (type == "file") {
|
} else if (type == "file") {
|
||||||
String path = Get("path");
|
String path = Get("path");
|
||||||
if (path.IsEmpty())
|
if (path.IsEmpty())
|
||||||
throw_exception(invalid_argument("'log' object of type 'file' must have a 'path' property"));
|
BOOST_THROW_EXCEPTION(invalid_argument("'log' object of type 'file' must have a 'path' property"));
|
||||||
|
|
||||||
StreamLogger::Ptr slogger = boost::make_shared<StreamLogger>();
|
StreamLogger::Ptr slogger = boost::make_shared<StreamLogger>();
|
||||||
slogger->OpenFile(path);
|
slogger->OpenFile(path);
|
||||||
|
@ -58,7 +58,7 @@ Logger::Logger(const Dictionary::Ptr& properties)
|
||||||
} else if (type == "console") {
|
} else if (type == "console") {
|
||||||
impl = boost::make_shared<StreamLogger>(&std::cout);
|
impl = boost::make_shared<StreamLogger>(&std::cout);
|
||||||
} else {
|
} else {
|
||||||
throw_exception(runtime_error("Unknown log type: " + type));
|
BOOST_THROW_EXCEPTION(runtime_error("Unknown log type: " + type));
|
||||||
}
|
}
|
||||||
|
|
||||||
impl->m_Config = this;
|
impl->m_Config = this;
|
||||||
|
@ -150,7 +150,7 @@ String Logger::SeverityToString(LogSeverity severity)
|
||||||
case LogCritical:
|
case LogCritical:
|
||||||
return "critical";
|
return "critical";
|
||||||
default:
|
default:
|
||||||
throw_exception(invalid_argument("Invalid severity."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Invalid severity."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ LogSeverity Logger::StringToSeverity(const String& severity)
|
||||||
else if (severity == "critical")
|
else if (severity == "critical")
|
||||||
return LogCritical;
|
return LogCritical;
|
||||||
else
|
else
|
||||||
throw_exception(invalid_argument("Invalid severity: " + severity));
|
BOOST_THROW_EXCEPTION(invalid_argument("Invalid severity: " + severity));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -37,7 +37,7 @@ bool NetString::ReadStringFromStream(const Stream::Ptr& stream, String *str)
|
||||||
char *buffer = static_cast<char *>(malloc(buffer_length));
|
char *buffer = static_cast<char *>(malloc(buffer_length));
|
||||||
|
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
throw_exception(bad_alloc());
|
BOOST_THROW_EXCEPTION(bad_alloc());
|
||||||
|
|
||||||
peek_length = stream->Peek(buffer, buffer_length);
|
peek_length = stream->Peek(buffer, buffer_length);
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ bool NetString::ReadStringFromStream(const Stream::Ptr& stream, String *str)
|
||||||
/* no leading zeros allowed */
|
/* no leading zeros allowed */
|
||||||
if (buffer[0] == '0' && isdigit(buffer[1])) {
|
if (buffer[0] == '0' && isdigit(buffer[1])) {
|
||||||
free(buffer);
|
free(buffer);
|
||||||
throw_exception(invalid_argument("Invalid netString (leading zero)"));
|
BOOST_THROW_EXCEPTION(invalid_argument("Invalid netString (leading zero)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t len, i;
|
size_t len, i;
|
||||||
|
@ -60,7 +60,7 @@ bool NetString::ReadStringFromStream(const Stream::Ptr& stream, String *str)
|
||||||
/* length specifier must have at most 9 characters */
|
/* length specifier must have at most 9 characters */
|
||||||
if (i >= 9) {
|
if (i >= 9) {
|
||||||
free(buffer);
|
free(buffer);
|
||||||
throw_exception(invalid_argument("Length specifier must not exceed 9 characters"));
|
BOOST_THROW_EXCEPTION(invalid_argument("Length specifier must not exceed 9 characters"));
|
||||||
}
|
}
|
||||||
|
|
||||||
len = len * 10 + (buffer[i] - '0');
|
len = len * 10 + (buffer[i] - '0');
|
||||||
|
@ -73,7 +73,7 @@ bool NetString::ReadStringFromStream(const Stream::Ptr& stream, String *str)
|
||||||
|
|
||||||
if (new_buffer == NULL) {
|
if (new_buffer == NULL) {
|
||||||
free(buffer);
|
free(buffer);
|
||||||
throw_exception(bad_alloc());
|
BOOST_THROW_EXCEPTION(bad_alloc());
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer = new_buffer;
|
buffer = new_buffer;
|
||||||
|
@ -86,13 +86,13 @@ bool NetString::ReadStringFromStream(const Stream::Ptr& stream, String *str)
|
||||||
/* check for the colon delimiter */
|
/* check for the colon delimiter */
|
||||||
if (buffer[i] != ':') {
|
if (buffer[i] != ':') {
|
||||||
free(buffer);
|
free(buffer);
|
||||||
throw_exception(invalid_argument("Invalid NetString (missing :)"));
|
BOOST_THROW_EXCEPTION(invalid_argument("Invalid NetString (missing :)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check for the comma delimiter after the String */
|
/* check for the comma delimiter after the String */
|
||||||
if (buffer[i + 1 + len] != ',') {
|
if (buffer[i + 1 + len] != ',') {
|
||||||
free(buffer);
|
free(buffer);
|
||||||
throw_exception(invalid_argument("Invalid NetString (missing ,)"));
|
BOOST_THROW_EXCEPTION(invalid_argument("Invalid NetString (missing ,)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
*str = String(&buffer[i + 1], &buffer[i + 1 + len]);
|
*str = String(&buffer[i + 1], &buffer[i + 1 + len]);
|
||||||
|
|
|
@ -116,7 +116,7 @@ void Object::PrintMemoryProfile(void)
|
||||||
|
|
||||||
dictfp.close();
|
dictfp.close();
|
||||||
if (rename("dictionaries.dump.tmp", "dictionaries.dump") < 0)
|
if (rename("dictionaries.dump.tmp", "dictionaries.dump") < 0)
|
||||||
throw_exception(PosixException("rename() failed", errno));
|
BOOST_THROW_EXCEPTION(PosixException("rename() failed", errno));
|
||||||
|
|
||||||
String type;
|
String type;
|
||||||
int count;
|
int count;
|
||||||
|
|
|
@ -152,7 +152,7 @@ void Process::InitTask(void)
|
||||||
#endif /* _MSC_VER */
|
#endif /* _MSC_VER */
|
||||||
|
|
||||||
if (m_FP == NULL)
|
if (m_FP == NULL)
|
||||||
throw_exception(runtime_error("Could not create process."));
|
BOOST_THROW_EXCEPTION(runtime_error("Could not create process."));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Process::RunTask(void)
|
bool Process::RunTask(void)
|
||||||
|
|
|
@ -74,10 +74,10 @@ void Socket::SetFD(SOCKET fd)
|
||||||
int flags;
|
int flags;
|
||||||
flags = fcntl(fd, F_GETFL, 0);
|
flags = fcntl(fd, F_GETFL, 0);
|
||||||
if (flags < 0)
|
if (flags < 0)
|
||||||
throw_exception(PosixException("fcntl failed", errno));
|
BOOST_THROW_EXCEPTION(PosixException("fcntl failed", errno));
|
||||||
|
|
||||||
if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0)
|
if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0)
|
||||||
throw_exception(PosixException("fcntl failed", errno));
|
BOOST_THROW_EXCEPTION(PosixException("fcntl failed", errno));
|
||||||
#else /* F_GETFL */
|
#else /* F_GETFL */
|
||||||
unsigned long lTrue = 1;
|
unsigned long lTrue = 1;
|
||||||
ioctlsocket(fd, FIONBIO, &lTrue);
|
ioctlsocket(fd, FIONBIO, &lTrue);
|
||||||
|
@ -154,7 +154,7 @@ int Socket::GetLastSocketError(void)
|
||||||
*/
|
*/
|
||||||
void Socket::HandleException(void)
|
void Socket::HandleException(void)
|
||||||
{
|
{
|
||||||
throw_exception(SocketException("select() returned fd in except fdset", GetError()));
|
BOOST_THROW_EXCEPTION(SocketException("select() returned fd in except fdset", GetError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -169,7 +169,7 @@ String Socket::GetAddressFromSockaddr(sockaddr *address, socklen_t len)
|
||||||
|
|
||||||
if (getnameinfo(address, len, host, sizeof(host), service,
|
if (getnameinfo(address, len, host, sizeof(host), service,
|
||||||
sizeof(service), NI_NUMERICHOST | NI_NUMERICSERV) < 0)
|
sizeof(service), NI_NUMERICHOST | NI_NUMERICSERV) < 0)
|
||||||
throw_exception(SocketException("getnameinfo() failed",
|
BOOST_THROW_EXCEPTION(SocketException("getnameinfo() failed",
|
||||||
GetLastSocketError()));
|
GetLastSocketError()));
|
||||||
|
|
||||||
stringstream s;
|
stringstream s;
|
||||||
|
@ -190,7 +190,7 @@ String Socket::GetClientAddress(void)
|
||||||
socklen_t len = sizeof(sin);
|
socklen_t len = sizeof(sin);
|
||||||
|
|
||||||
if (getsockname(GetFD(), (sockaddr *)&sin, &len) < 0)
|
if (getsockname(GetFD(), (sockaddr *)&sin, &len) < 0)
|
||||||
throw_exception(SocketException("getsockname() failed", GetError()));
|
BOOST_THROW_EXCEPTION(SocketException("getsockname() failed", GetError()));
|
||||||
|
|
||||||
return GetAddressFromSockaddr((sockaddr *)&sin, len);
|
return GetAddressFromSockaddr((sockaddr *)&sin, len);
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ String Socket::GetPeerAddress(void)
|
||||||
socklen_t len = sizeof(sin);
|
socklen_t len = sizeof(sin);
|
||||||
|
|
||||||
if (getpeername(GetFD(), (sockaddr *)&sin, &len) < 0)
|
if (getpeername(GetFD(), (sockaddr *)&sin, &len) < 0)
|
||||||
throw_exception(SocketException("getpeername() failed", GetError()));
|
BOOST_THROW_EXCEPTION(SocketException("getpeername() failed", GetError()));
|
||||||
|
|
||||||
return GetAddressFromSockaddr((sockaddr *)&sin, len);
|
return GetAddressFromSockaddr((sockaddr *)&sin, len);
|
||||||
}
|
}
|
||||||
|
@ -269,7 +269,7 @@ void Socket::ReadThreadProc(void)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
throw_exception(SocketException("select() failed", GetError()));
|
BOOST_THROW_EXCEPTION(SocketException("select() failed", GetError()));
|
||||||
|
|
||||||
if (FD_ISSET(fd, &readfds))
|
if (FD_ISSET(fd, &readfds))
|
||||||
HandleReadable();
|
HandleReadable();
|
||||||
|
@ -327,7 +327,7 @@ void Socket::WriteThreadProc(void)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
throw_exception(SocketException("select() failed", GetError()));
|
BOOST_THROW_EXCEPTION(SocketException("select() failed", GetError()));
|
||||||
|
|
||||||
if (FD_ISSET(fd, &writefds))
|
if (FD_ISSET(fd, &writefds))
|
||||||
HandleWritable();
|
HandleWritable();
|
||||||
|
@ -446,7 +446,7 @@ void Socket::Write(const void *buffer, size_t size)
|
||||||
void Socket::Listen(void)
|
void Socket::Listen(void)
|
||||||
{
|
{
|
||||||
if (listen(GetFD(), SOMAXCONN) < 0)
|
if (listen(GetFD(), SOMAXCONN) < 0)
|
||||||
throw_exception(SocketException("listen() failed", GetError()));
|
BOOST_THROW_EXCEPTION(SocketException("listen() failed", GetError()));
|
||||||
|
|
||||||
m_Listening = true;
|
m_Listening = true;
|
||||||
}
|
}
|
||||||
|
@ -497,7 +497,7 @@ void Socket::HandleWritableClient(void)
|
||||||
rc = send(GetFD(), data, count, 0);
|
rc = send(GetFD(), data, count, 0);
|
||||||
|
|
||||||
if (rc <= 0)
|
if (rc <= 0)
|
||||||
throw_exception(SocketException("send() failed", GetError()));
|
BOOST_THROW_EXCEPTION(SocketException("send() failed", GetError()));
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(m_QueueMutex);
|
boost::mutex::scoped_lock lock(m_QueueMutex);
|
||||||
|
@ -528,7 +528,7 @@ void Socket::HandleReadableClient(void)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (rc <= 0)
|
if (rc <= 0)
|
||||||
throw_exception(SocketException("recv() failed", GetError()));
|
BOOST_THROW_EXCEPTION(SocketException("recv() failed", GetError()));
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(m_QueueMutex);
|
boost::mutex::scoped_lock lock(m_QueueMutex);
|
||||||
|
@ -561,7 +561,7 @@ void Socket::HandleReadableServer(void)
|
||||||
fd = accept(GetFD(), (sockaddr *)&addr, &addrlen);
|
fd = accept(GetFD(), (sockaddr *)&addr, &addrlen);
|
||||||
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
throw_exception(SocketException("accept() failed", GetError()));
|
BOOST_THROW_EXCEPTION(SocketException("accept() failed", GetError()));
|
||||||
|
|
||||||
TcpSocket::Ptr client = boost::make_shared<TcpSocket>();
|
TcpSocket::Ptr client = boost::make_shared<TcpSocket>();
|
||||||
client->SetFD(fd);
|
client->SetFD(fd);
|
||||||
|
|
|
@ -54,7 +54,7 @@ void StreamLogger::OpenFile(const String& filename)
|
||||||
stream->open(filename.CStr(), fstream::out | fstream::trunc);
|
stream->open(filename.CStr(), fstream::out | fstream::trunc);
|
||||||
|
|
||||||
if (!stream->good())
|
if (!stream->good())
|
||||||
throw_exception(runtime_error("Could not open logfile '" + filename + "'"));
|
BOOST_THROW_EXCEPTION(runtime_error("Could not open logfile '" + filename + "'"));
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
delete stream;
|
delete stream;
|
||||||
throw;
|
throw;
|
||||||
|
|
|
@ -52,7 +52,7 @@ void TcpSocket::Bind(String node, String service, int family)
|
||||||
|
|
||||||
if (getaddrinfo(node.IsEmpty() ? NULL : node.CStr(),
|
if (getaddrinfo(node.IsEmpty() ? NULL : node.CStr(),
|
||||||
service.CStr(), &hints, &result) < 0)
|
service.CStr(), &hints, &result) < 0)
|
||||||
throw_exception(SocketException("getaddrinfo() failed", GetLastSocketError()));
|
BOOST_THROW_EXCEPTION(SocketException("getaddrinfo() failed", GetLastSocketError()));
|
||||||
|
|
||||||
int fd = INVALID_SOCKET;
|
int fd = INVALID_SOCKET;
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ void TcpSocket::Bind(String node, String service, int family)
|
||||||
freeaddrinfo(result);
|
freeaddrinfo(result);
|
||||||
|
|
||||||
if (fd == INVALID_SOCKET)
|
if (fd == INVALID_SOCKET)
|
||||||
throw_exception(runtime_error("Could not create a suitable socket."));
|
BOOST_THROW_EXCEPTION(runtime_error("Could not create a suitable socket."));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -113,7 +113,7 @@ void TcpSocket::Connect(const String& node, const String& service)
|
||||||
int rc = getaddrinfo(node.CStr(), service.CStr(), &hints, &result);
|
int rc = getaddrinfo(node.CStr(), service.CStr(), &hints, &result);
|
||||||
|
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
throw_exception(SocketException("getaddrinfo() failed", GetLastSocketError()));
|
BOOST_THROW_EXCEPTION(SocketException("getaddrinfo() failed", GetLastSocketError()));
|
||||||
|
|
||||||
int fd = INVALID_SOCKET;
|
int fd = INVALID_SOCKET;
|
||||||
|
|
||||||
|
@ -149,5 +149,5 @@ void TcpSocket::Connect(const String& node, const String& service)
|
||||||
freeaddrinfo(result);
|
freeaddrinfo(result);
|
||||||
|
|
||||||
if (fd == INVALID_SOCKET)
|
if (fd == INVALID_SOCKET)
|
||||||
throw_exception(runtime_error("Could not create a suitable socket."));
|
BOOST_THROW_EXCEPTION(runtime_error("Could not create a suitable socket."));
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,10 +47,10 @@ void TlsStream::Start(void)
|
||||||
m_SSLContext.reset();
|
m_SSLContext.reset();
|
||||||
|
|
||||||
if (!m_SSL)
|
if (!m_SSL)
|
||||||
throw_exception(OpenSSLException("SSL_new failed", ERR_get_error()));
|
BOOST_THROW_EXCEPTION(OpenSSLException("SSL_new failed", ERR_get_error()));
|
||||||
|
|
||||||
if (!GetClientCertificate())
|
if (!GetClientCertificate())
|
||||||
throw_exception(logic_error("No X509 client certificate was specified."));
|
BOOST_THROW_EXCEPTION(logic_error("No X509 client certificate was specified."));
|
||||||
|
|
||||||
if (!m_SSLIndexInitialized) {
|
if (!m_SSLIndexInitialized) {
|
||||||
m_SSLIndex = SSL_get_ex_new_index(0, const_cast<char *>("TlsStream"), NULL, NULL, NULL);
|
m_SSLIndex = SSL_get_ex_new_index(0, const_cast<char *>("TlsStream"), NULL, NULL, NULL);
|
||||||
|
@ -142,7 +142,7 @@ void TlsStream::HandleIO(void)
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
I2Stream_check_exception(m_BIO);
|
I2Stream_check_exception(m_BIO);
|
||||||
throw_exception(OpenSSLException("SSL_do_handshake failed", ERR_get_error()));
|
BOOST_THROW_EXCEPTION(OpenSSLException("SSL_do_handshake failed", ERR_get_error()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ void TlsStream::HandleIO(void)
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
I2Stream_check_exception(m_BIO);
|
I2Stream_check_exception(m_BIO);
|
||||||
throw_exception(OpenSSLException("SSL_read failed", ERR_get_error()));
|
BOOST_THROW_EXCEPTION(OpenSSLException("SSL_read failed", ERR_get_error()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,7 +201,7 @@ void TlsStream::HandleIO(void)
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
I2Stream_check_exception(m_BIO);
|
I2Stream_check_exception(m_BIO);
|
||||||
throw_exception(OpenSSLException("SSL_write failed", ERR_get_error()));
|
BOOST_THROW_EXCEPTION(OpenSSLException("SSL_write failed", ERR_get_error()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ UnixSocket::UnixSocket(void)
|
||||||
int fd = socket(AF_UNIX, SOCK_STREAM, PF_UNIX);
|
int fd = socket(AF_UNIX, SOCK_STREAM, PF_UNIX);
|
||||||
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
throw_exception(PosixException("socket() failed", errno));
|
BOOST_THROW_EXCEPTION(PosixException("socket() failed", errno));
|
||||||
|
|
||||||
SetFD(fd);
|
SetFD(fd);
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ void UnixSocket::Bind(const String& path)
|
||||||
sun.sun_path[sizeof(sun.sun_path) - 1] = '\0';
|
sun.sun_path[sizeof(sun.sun_path) - 1] = '\0';
|
||||||
|
|
||||||
if (bind(GetFD(), (sockaddr *)&sun, SUN_LEN(&sun)) < 0)
|
if (bind(GetFD(), (sockaddr *)&sun, SUN_LEN(&sun)) < 0)
|
||||||
throw_exception(PosixException("bind() failed", errno));
|
BOOST_THROW_EXCEPTION(PosixException("bind() failed", errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnixSocket::Connect(const String& path)
|
void UnixSocket::Connect(const String& path)
|
||||||
|
@ -55,6 +55,6 @@ void UnixSocket::Connect(const String& path)
|
||||||
sun.sun_path[sizeof(sun.sun_path) - 1] = '\0';
|
sun.sun_path[sizeof(sun.sun_path) - 1] = '\0';
|
||||||
|
|
||||||
if (connect(GetFD(), (sockaddr *)&sun, SUN_LEN(&sun)) < 0 && errno != EINPROGRESS)
|
if (connect(GetFD(), (sockaddr *)&sun, SUN_LEN(&sun)) < 0 && errno != EINPROGRESS)
|
||||||
throw_exception(PosixException("connect() failed", errno));
|
BOOST_THROW_EXCEPTION(PosixException("connect() failed", errno));
|
||||||
}
|
}
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
|
@ -121,7 +121,7 @@ void Utility::Daemonize(void) {
|
||||||
|
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if (pid < 0)
|
if (pid < 0)
|
||||||
throw_exception(PosixException("fork() failed", errno));
|
BOOST_THROW_EXCEPTION(PosixException("fork() failed", errno));
|
||||||
|
|
||||||
if (pid)
|
if (pid)
|
||||||
_exit(0);
|
_exit(0);
|
||||||
|
@ -129,7 +129,7 @@ void Utility::Daemonize(void) {
|
||||||
fd = open("/dev/null", O_RDWR);
|
fd = open("/dev/null", O_RDWR);
|
||||||
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
throw_exception(PosixException("open() failed", errno));
|
BOOST_THROW_EXCEPTION(PosixException("open() failed", errno));
|
||||||
|
|
||||||
if (fd != STDIN_FILENO)
|
if (fd != STDIN_FILENO)
|
||||||
dup2(fd, STDIN_FILENO);
|
dup2(fd, STDIN_FILENO);
|
||||||
|
@ -144,7 +144,7 @@ void Utility::Daemonize(void) {
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
if (setsid() < 0)
|
if (setsid() < 0)
|
||||||
throw_exception(PosixException("setsid() failed", errno));
|
BOOST_THROW_EXCEPTION(PosixException("setsid() failed", errno));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,19 +179,19 @@ shared_ptr<SSL_CTX> Utility::MakeSSLContext(const String& pubkey, const String&
|
||||||
SSL_CTX_set_mode(sslContext.get(), SSL_MODE_ENABLE_PARTIAL_WRITE | SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);
|
SSL_CTX_set_mode(sslContext.get(), SSL_MODE_ENABLE_PARTIAL_WRITE | SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);
|
||||||
|
|
||||||
if (!SSL_CTX_use_certificate_chain_file(sslContext.get(), pubkey.CStr()))
|
if (!SSL_CTX_use_certificate_chain_file(sslContext.get(), pubkey.CStr()))
|
||||||
throw_exception(OpenSSLException("Could not load public X509 key file", ERR_get_error()));
|
BOOST_THROW_EXCEPTION(OpenSSLException("Could not load public X509 key file", ERR_get_error()));
|
||||||
|
|
||||||
if (!SSL_CTX_use_PrivateKey_file(sslContext.get(), privkey.CStr(), SSL_FILETYPE_PEM))
|
if (!SSL_CTX_use_PrivateKey_file(sslContext.get(), privkey.CStr(), SSL_FILETYPE_PEM))
|
||||||
throw_exception(OpenSSLException("Could not load private X509 key file", ERR_get_error()));
|
BOOST_THROW_EXCEPTION(OpenSSLException("Could not load private X509 key file", ERR_get_error()));
|
||||||
|
|
||||||
if (!SSL_CTX_load_verify_locations(sslContext.get(), cakey.CStr(), NULL))
|
if (!SSL_CTX_load_verify_locations(sslContext.get(), cakey.CStr(), NULL))
|
||||||
throw_exception(OpenSSLException("Could not load public CA key file", ERR_get_error()));
|
BOOST_THROW_EXCEPTION(OpenSSLException("Could not load public CA key file", ERR_get_error()));
|
||||||
|
|
||||||
STACK_OF(X509_NAME) *cert_names;
|
STACK_OF(X509_NAME) *cert_names;
|
||||||
|
|
||||||
cert_names = SSL_load_client_CA_file(cakey.CStr());
|
cert_names = SSL_load_client_CA_file(cakey.CStr());
|
||||||
if (cert_names == NULL)
|
if (cert_names == NULL)
|
||||||
throw_exception(OpenSSLException("SSL_load_client_CA_file() failed", ERR_get_error()));
|
BOOST_THROW_EXCEPTION(OpenSSLException("SSL_load_client_CA_file() failed", ERR_get_error()));
|
||||||
|
|
||||||
SSL_CTX_set_client_CA_list(sslContext.get(), cert_names);
|
SSL_CTX_set_client_CA_list(sslContext.get(), cert_names);
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ String Utility::GetCertificateCN(const shared_ptr<X509>& certificate)
|
||||||
NID_commonName, buffer, sizeof(buffer));
|
NID_commonName, buffer, sizeof(buffer));
|
||||||
|
|
||||||
if (rc == -1)
|
if (rc == -1)
|
||||||
throw_exception(OpenSSLException("X509 certificate has no CN"
|
BOOST_THROW_EXCEPTION(OpenSSLException("X509 certificate has no CN"
|
||||||
" attribute", ERR_get_error()));
|
" attribute", ERR_get_error()));
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
|
@ -230,16 +230,16 @@ shared_ptr<X509> Utility::GetX509Certificate(const String& pemfile)
|
||||||
BIO *fpcert = BIO_new(BIO_s_file());
|
BIO *fpcert = BIO_new(BIO_s_file());
|
||||||
|
|
||||||
if (fpcert == NULL)
|
if (fpcert == NULL)
|
||||||
throw_exception(OpenSSLException("BIO_new failed",
|
BOOST_THROW_EXCEPTION(OpenSSLException("BIO_new failed",
|
||||||
ERR_get_error()));
|
ERR_get_error()));
|
||||||
|
|
||||||
if (BIO_read_filename(fpcert, pemfile.CStr()) < 0)
|
if (BIO_read_filename(fpcert, pemfile.CStr()) < 0)
|
||||||
throw_exception(OpenSSLException("BIO_read_filename failed",
|
BOOST_THROW_EXCEPTION(OpenSSLException("BIO_read_filename failed",
|
||||||
ERR_get_error()));
|
ERR_get_error()));
|
||||||
|
|
||||||
cert = PEM_read_bio_X509_AUX(fpcert, NULL, NULL, NULL);
|
cert = PEM_read_bio_X509_AUX(fpcert, NULL, NULL, NULL);
|
||||||
if (cert == NULL)
|
if (cert == NULL)
|
||||||
throw_exception(OpenSSLException("PEM_read_bio_X509_AUX failed",
|
BOOST_THROW_EXCEPTION(OpenSSLException("PEM_read_bio_X509_AUX failed",
|
||||||
ERR_get_error()));
|
ERR_get_error()));
|
||||||
|
|
||||||
BIO_free(fpcert);
|
BIO_free(fpcert);
|
||||||
|
@ -271,14 +271,14 @@ String Utility::DirName(const String& path)
|
||||||
String result;
|
String result;
|
||||||
|
|
||||||
if (dir == NULL)
|
if (dir == NULL)
|
||||||
throw_exception(bad_alloc());
|
BOOST_THROW_EXCEPTION(bad_alloc());
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
result = dirname(dir);
|
result = dirname(dir);
|
||||||
#else /* _WIN32 */
|
#else /* _WIN32 */
|
||||||
if (!PathRemoveFileSpec(dir)) {
|
if (!PathRemoveFileSpec(dir)) {
|
||||||
free(dir);
|
free(dir);
|
||||||
throw_exception(Win32Exception("PathRemoveFileSpec() failed",
|
BOOST_THROW_EXCEPTION(Win32Exception("PathRemoveFileSpec() failed",
|
||||||
GetLastError()));
|
GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,7 +305,7 @@ String Utility::BaseName(const String& path)
|
||||||
String result;
|
String result;
|
||||||
|
|
||||||
if (dir == NULL)
|
if (dir == NULL)
|
||||||
throw_exception(bad_alloc());
|
BOOST_THROW_EXCEPTION(bad_alloc());
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
result = basename(dir);
|
result = basename(dir);
|
||||||
|
@ -356,7 +356,7 @@ double Utility::GetTime(void)
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
||||||
if (gettimeofday(&tv, NULL) < 0)
|
if (gettimeofday(&tv, NULL) < 0)
|
||||||
throw_exception(PosixException("gettimeofday() failed", errno));
|
BOOST_THROW_EXCEPTION(PosixException("gettimeofday() failed", errno));
|
||||||
|
|
||||||
return tv.tv_sec + tv.tv_usec / 1000000.0;
|
return tv.tv_sec + tv.tv_usec / 1000000.0;
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
@ -418,12 +418,12 @@ Utility::LoadIcingaLibrary(const String& library, bool module)
|
||||||
HMODULE hModule = LoadLibrary(path.CStr());
|
HMODULE hModule = LoadLibrary(path.CStr());
|
||||||
|
|
||||||
if (hModule == NULL)
|
if (hModule == NULL)
|
||||||
throw_exception(Win32Exception("LoadLibrary('" + path + "') failed", GetLastError()));
|
BOOST_THROW_EXCEPTION(Win32Exception("LoadLibrary('" + path + "') failed", GetLastError()));
|
||||||
#else /* _WIN32 */
|
#else /* _WIN32 */
|
||||||
lt_dlhandle hModule = lt_dlopen(path.CStr());
|
lt_dlhandle hModule = lt_dlopen(path.CStr());
|
||||||
|
|
||||||
if (hModule == NULL) {
|
if (hModule == NULL) {
|
||||||
throw_exception(runtime_error("Could not load library '" + path + "': " + lt_dlerror()));
|
BOOST_THROW_EXCEPTION(runtime_error("Could not load library '" + path + "': " + lt_dlerror()));
|
||||||
}
|
}
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
|
@ -460,7 +460,7 @@ bool Utility::Glob(const String& pathSpec, const function<void (const String&)>&
|
||||||
if (errorCode == ERROR_FILE_NOT_FOUND)
|
if (errorCode == ERROR_FILE_NOT_FOUND)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
throw_exception(Win32Exception("FindFirstFile() failed", errorCode));
|
BOOST_THROW_EXCEPTION(Win32Exception("FindFirstFile() failed", errorCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
@ -468,7 +468,7 @@ bool Utility::Glob(const String& pathSpec, const function<void (const String&)>&
|
||||||
} while (FindNextFile(handle, &wfd));
|
} while (FindNextFile(handle, &wfd));
|
||||||
|
|
||||||
if (!FindClose(handle))
|
if (!FindClose(handle))
|
||||||
throw_exception(Win32Exception("FindClose() failed", GetLastError()));
|
BOOST_THROW_EXCEPTION(Win32Exception("FindClose() failed", GetLastError()));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
#else /* _WIN32 */
|
#else /* _WIN32 */
|
||||||
|
@ -480,7 +480,7 @@ bool Utility::Glob(const String& pathSpec, const function<void (const String&)>&
|
||||||
if (rc == GLOB_NOMATCH)
|
if (rc == GLOB_NOMATCH)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
throw_exception(PosixException("glob() failed", errno));
|
BOOST_THROW_EXCEPTION(PosixException("glob() failed", errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gr.gl_pathc == 0) {
|
if (gr.gl_pathc == 0) {
|
||||||
|
@ -515,7 +515,7 @@ void Utility::WaitUntil(const function<bool (void)>& predicate)
|
||||||
* (like spawning a process) until the application instance
|
* (like spawning a process) until the application instance
|
||||||
* has been initialized. */
|
* has been initialized. */
|
||||||
if (!instance)
|
if (!instance)
|
||||||
throw_exception(runtime_error("Waiting for predicate failed: Application instance is not initialized."));
|
BOOST_THROW_EXCEPTION(runtime_error("Waiting for predicate failed: Application instance is not initialized."));
|
||||||
|
|
||||||
instance->ProcessEvents();
|
instance->ProcessEvents();
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ Value Value::FromJson(cJSON *json)
|
||||||
else if (json->type == cJSON_NULL)
|
else if (json->type == cJSON_NULL)
|
||||||
return Value();
|
return Value();
|
||||||
else
|
else
|
||||||
throw_exception(invalid_argument("Unsupported JSON type."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Unsupported JSON type."));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -126,7 +126,7 @@ cJSON *Value::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_exception(runtime_error("Invalid variant type."));
|
BOOST_THROW_EXCEPTION(runtime_error("Invalid variant type."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ Value Value::Deserialize(const String& jsonString)
|
||||||
cJSON *json = cJSON_Parse(jsonString.CStr());
|
cJSON *json = cJSON_Parse(jsonString.CStr());
|
||||||
|
|
||||||
if (!json)
|
if (!json)
|
||||||
throw_exception(runtime_error("Invalid JSON String"));
|
BOOST_THROW_EXCEPTION(runtime_error("Invalid JSON String"));
|
||||||
|
|
||||||
Value value = FromJson(json);
|
Value value = FromJson(json);
|
||||||
cJSON_Delete(json);
|
cJSON_Delete(json);
|
||||||
|
|
|
@ -67,7 +67,7 @@ public:
|
||||||
Object::Ptr object = dynamic_pointer_cast<Object>(value);
|
Object::Ptr object = dynamic_pointer_cast<Object>(value);
|
||||||
|
|
||||||
if (!object)
|
if (!object)
|
||||||
throw_exception(invalid_argument("shared_ptr value type must inherit from Object class."));
|
BOOST_THROW_EXCEPTION(invalid_argument("shared_ptr value type must inherit from Object class."));
|
||||||
|
|
||||||
m_Value = object;
|
m_Value = object;
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ public:
|
||||||
shared_ptr<T> object = dynamic_pointer_cast<T>(boost::get<Object::Ptr>(m_Value));
|
shared_ptr<T> object = dynamic_pointer_cast<T>(boost::get<Object::Ptr>(m_Value));
|
||||||
|
|
||||||
if (!object)
|
if (!object)
|
||||||
throw_exception(bad_cast());
|
BOOST_THROW_EXCEPTION(bad_cast());
|
||||||
|
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
|
@ -237,7 +237,7 @@ void yyerror(YYLTYPE *locp, ConfigCompiler *, const char *err)
|
||||||
{
|
{
|
||||||
stringstream message;
|
stringstream message;
|
||||||
message << *locp << ": " << err;
|
message << *locp << ": " << err;
|
||||||
throw_exception(runtime_error(message.str()));
|
ConfigCompilerContext::GetContext()->AddError(false, message.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
int yyparse(ConfigCompiler *context);
|
int yyparse(ConfigCompiler *context);
|
||||||
|
@ -257,7 +257,7 @@ void ConfigCompiler::Compile(void)
|
||||||
try {
|
try {
|
||||||
yyparse(this);
|
yyparse(this);
|
||||||
} catch (const exception& ex) {
|
} catch (const exception& ex) {
|
||||||
ConfigCompilerContext::GetContext()->AddError(false, ex.what());
|
ConfigCompilerContext::GetContext()->AddError(false, boost::diagnostic_information(ex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1671,7 +1671,7 @@ yyreduce:
|
||||||
|
|
||||||
if (!m_Type) {
|
if (!m_Type) {
|
||||||
if ((yyvsp[(1) - (3)].num))
|
if ((yyvsp[(1) - (3)].num))
|
||||||
throw_exception(invalid_argument("partial type definition for unknown type '" + name + "'"));
|
BOOST_THROW_EXCEPTION(invalid_argument("Partial type definition for unknown type '" + name + "'"));
|
||||||
|
|
||||||
m_Type = boost::make_shared<ConfigType>(name, yylloc);
|
m_Type = boost::make_shared<ConfigType>(name, yylloc);
|
||||||
ConfigCompilerContext::GetContext()->AddType(m_Type);
|
ConfigCompilerContext::GetContext()->AddType(m_Type);
|
||||||
|
|
|
@ -87,7 +87,7 @@ void yyerror(YYLTYPE *locp, ConfigCompiler *, const char *err)
|
||||||
{
|
{
|
||||||
stringstream message;
|
stringstream message;
|
||||||
message << *locp << ": " << err;
|
message << *locp << ": " << err;
|
||||||
throw_exception(runtime_error(message.str()));
|
ConfigCompilerContext::GetContext()->AddError(false, message.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
int yyparse(ConfigCompiler *context);
|
int yyparse(ConfigCompiler *context);
|
||||||
|
@ -107,7 +107,7 @@ void ConfigCompiler::Compile(void)
|
||||||
try {
|
try {
|
||||||
yyparse(this);
|
yyparse(this);
|
||||||
} catch (const exception& ex) {
|
} catch (const exception& ex) {
|
||||||
ConfigCompilerContext::GetContext()->AddError(false, ex.what());
|
ConfigCompilerContext::GetContext()->AddError(false, boost::diagnostic_information(ex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ type: partial_specifier T_TYPE identifier
|
||||||
|
|
||||||
if (!m_Type) {
|
if (!m_Type) {
|
||||||
if ($1)
|
if ($1)
|
||||||
throw_exception(invalid_argument("partial type definition for unknown type '" + name + "'"));
|
BOOST_THROW_EXCEPTION(invalid_argument("Partial type definition for unknown type '" + name + "'"));
|
||||||
|
|
||||||
m_Type = boost::make_shared<ConfigType>(name, yylloc);
|
m_Type = boost::make_shared<ConfigType>(name, yylloc);
|
||||||
ConfigCompilerContext::GetContext()->AddType(m_Type);
|
ConfigCompilerContext::GetContext()->AddType(m_Type);
|
||||||
|
|
|
@ -138,7 +138,7 @@ void ConfigCompiler::CompileFile(const String& path)
|
||||||
stream.open(path.CStr(), ifstream::in);
|
stream.open(path.CStr(), ifstream::in);
|
||||||
|
|
||||||
if (!stream)
|
if (!stream)
|
||||||
throw_exception(invalid_argument("Could not open config file: " + path));
|
BOOST_THROW_EXCEPTION(invalid_argument("Could not open config file: " + path));
|
||||||
|
|
||||||
Logger::Write(LogInformation, "config", "Compiling config file: " + path);
|
Logger::Write(LogInformation, "config", "Compiling config file: " + path);
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ void ConfigCompiler::HandleFileInclude(const String& include, bool search,
|
||||||
if (!Utility::Glob(includePath, boost::bind(&ConfigCompiler::CompileFile, _1))) {
|
if (!Utility::Glob(includePath, boost::bind(&ConfigCompiler::CompileFile, _1))) {
|
||||||
stringstream msgbuf;
|
stringstream msgbuf;
|
||||||
msgbuf << "Include file '" + include + "' does not exist (or no files found for pattern): " << debuginfo;
|
msgbuf << "Include file '" + include + "' does not exist (or no files found for pattern): " << debuginfo;
|
||||||
throw_exception(invalid_argument(msgbuf.str()));
|
BOOST_THROW_EXCEPTION(invalid_argument(msgbuf.str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,7 @@ void ConfigItem::InternalLink(const Dictionary::Ptr& dictionary) const
|
||||||
stringstream message;
|
stringstream message;
|
||||||
message << "Parent object '" << name << "' does not"
|
message << "Parent object '" << name << "' does not"
|
||||||
" exist (" << m_DebugInfo << ")";
|
" exist (" << m_DebugInfo << ")";
|
||||||
throw_exception(domain_error(message.str()));
|
BOOST_THROW_EXCEPTION(domain_error(message.str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
parent->InternalLink(dictionary);
|
parent->InternalLink(dictionary);
|
||||||
|
@ -169,7 +169,7 @@ DynamicObject::Ptr ConfigItem::Commit(void)
|
||||||
DynamicType::Ptr dtype = DynamicType::GetByName(GetType());
|
DynamicType::Ptr dtype = DynamicType::GetByName(GetType());
|
||||||
|
|
||||||
if (!dtype)
|
if (!dtype)
|
||||||
throw_exception(runtime_error("Type '" + GetType() + "' does not exist."));
|
BOOST_THROW_EXCEPTION(runtime_error("Type '" + GetType() + "' does not exist."));
|
||||||
|
|
||||||
if (!dobj)
|
if (!dobj)
|
||||||
dobj = dtype->GetObject(GetName());
|
dobj = dtype->GetObject(GetName());
|
||||||
|
|
|
@ -90,19 +90,19 @@ ConfigItem::Ptr ConfigItemBuilder::Compile(void)
|
||||||
if (m_Type.IsEmpty()) {
|
if (m_Type.IsEmpty()) {
|
||||||
stringstream msgbuf;
|
stringstream msgbuf;
|
||||||
msgbuf << "The type name of an object may not be empty: " << m_DebugInfo;
|
msgbuf << "The type name of an object may not be empty: " << m_DebugInfo;
|
||||||
throw_exception(invalid_argument(msgbuf.str()));
|
BOOST_THROW_EXCEPTION(invalid_argument(msgbuf.str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DynamicType::GetByName(m_Type)) {
|
if (!DynamicType::GetByName(m_Type)) {
|
||||||
stringstream msgbuf;
|
stringstream msgbuf;
|
||||||
msgbuf << "The type '" + m_Type + "' is unknown: " << m_DebugInfo;
|
msgbuf << "The type '" + m_Type + "' is unknown: " << m_DebugInfo;
|
||||||
throw_exception(invalid_argument(msgbuf.str()));
|
BOOST_THROW_EXCEPTION(invalid_argument(msgbuf.str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_Name.IsEmpty()) {
|
if (m_Name.IsEmpty()) {
|
||||||
stringstream msgbuf;
|
stringstream msgbuf;
|
||||||
msgbuf << "The name of an object may not be empty: " << m_DebugInfo;
|
msgbuf << "The name of an object may not be empty: " << m_DebugInfo;
|
||||||
throw_exception(invalid_argument(msgbuf.str()));
|
BOOST_THROW_EXCEPTION(invalid_argument(msgbuf.str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpressionList::Ptr exprl = boost::make_shared<ExpressionList>();
|
ExpressionList::Ptr exprl = boost::make_shared<ExpressionList>();
|
||||||
|
|
|
@ -117,7 +117,7 @@ void ConfigType::ValidateDictionary(const Dictionary::Ptr& dictionary,
|
||||||
ScriptFunction::Ptr func = ScriptFunction::GetByName(validator);
|
ScriptFunction::Ptr func = ScriptFunction::GetByName(validator);
|
||||||
|
|
||||||
if (!func)
|
if (!func)
|
||||||
throw_exception(invalid_argument("Validator function '" + validator + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Validator function '" + validator + "' does not exist."));
|
||||||
|
|
||||||
vector<Value> arguments;
|
vector<Value> arguments;
|
||||||
arguments.push_back(LocationToString(locations));
|
arguments.push_back(LocationToString(locations));
|
||||||
|
|
|
@ -46,7 +46,7 @@ void Expression::Execute(const Dictionary::Ptr& dictionary) const
|
||||||
switch (m_Operator) {
|
switch (m_Operator) {
|
||||||
case OperatorExecute:
|
case OperatorExecute:
|
||||||
if (!valueExprl)
|
if (!valueExprl)
|
||||||
throw_exception(invalid_argument("Operand for OperatorExecute must be an ExpressionList."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Operand for OperatorExecute must be an ExpressionList."));
|
||||||
|
|
||||||
valueExprl->Execute(dictionary);
|
valueExprl->Execute(dictionary);
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ void Expression::Execute(const Dictionary::Ptr& dictionary) const
|
||||||
" += (non-dictionary and"
|
" += (non-dictionary and"
|
||||||
" dictionary) ("
|
" dictionary) ("
|
||||||
<< m_DebugInfo << ")";
|
<< m_DebugInfo << ")";
|
||||||
throw_exception(domain_error(message.str()));
|
BOOST_THROW_EXCEPTION(domain_error(message.str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
dict = boost::make_shared<Dictionary>();
|
dict = boost::make_shared<Dictionary>();
|
||||||
|
@ -94,13 +94,13 @@ void Expression::Execute(const Dictionary::Ptr& dictionary) const
|
||||||
stringstream message;
|
stringstream message;
|
||||||
message << "+= only works for dictionaries ("
|
message << "+= only works for dictionaries ("
|
||||||
<< m_DebugInfo << ")";
|
<< m_DebugInfo << ")";
|
||||||
throw_exception(domain_error(message.str()));
|
BOOST_THROW_EXCEPTION(domain_error(message.str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw_exception(runtime_error("Not yet implemented."));
|
BOOST_THROW_EXCEPTION(runtime_error("Not yet implemented."));
|
||||||
}
|
}
|
||||||
|
|
||||||
dictionary->Set(m_Key, newValue);
|
dictionary->Set(m_Key, newValue);
|
||||||
|
@ -154,7 +154,7 @@ void Expression::DumpValue(ostream& fp, int indent, const Value& value, bool inl
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw_exception(runtime_error("Encountered unknown type while dumping value."));
|
BOOST_THROW_EXCEPTION(runtime_error("Encountered unknown type while dumping value."));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Expression::Dump(ostream& fp, int indent) const
|
void Expression::Dump(ostream& fp, int indent) const
|
||||||
|
@ -177,7 +177,7 @@ void Expression::Dump(ostream& fp, int indent) const
|
||||||
fp << "+=";
|
fp << "+=";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw_exception(runtime_error("Not yet implemented."));
|
BOOST_THROW_EXCEPTION(runtime_error("Not yet implemented."));
|
||||||
}
|
}
|
||||||
|
|
||||||
fp << " ";
|
fp << " ";
|
||||||
|
|
|
@ -30,12 +30,12 @@ void ExternalCommandProcessor::Execute(const String& line)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (line[0] != '[')
|
if (line[0] != '[')
|
||||||
throw_exception(invalid_argument("Missing timestamp in command: " + line));
|
BOOST_THROW_EXCEPTION(invalid_argument("Missing timestamp in command: " + line));
|
||||||
|
|
||||||
size_t pos = line.FindFirstOf("]");
|
size_t pos = line.FindFirstOf("]");
|
||||||
|
|
||||||
if (pos == String::NPos)
|
if (pos == String::NPos)
|
||||||
throw_exception(invalid_argument("Missing timestamp in command: " + line));
|
BOOST_THROW_EXCEPTION(invalid_argument("Missing timestamp in command: " + line));
|
||||||
|
|
||||||
String timestamp = line.SubStr(1, pos - 1);
|
String timestamp = line.SubStr(1, pos - 1);
|
||||||
String args = line.SubStr(pos + 2, String::NPos);
|
String args = line.SubStr(pos + 2, String::NPos);
|
||||||
|
@ -43,12 +43,12 @@ void ExternalCommandProcessor::Execute(const String& line)
|
||||||
double ts = Convert::ToDouble(timestamp);
|
double ts = Convert::ToDouble(timestamp);
|
||||||
|
|
||||||
if (ts == 0)
|
if (ts == 0)
|
||||||
throw_exception(invalid_argument("Invalid timestamp in command: " + line));
|
BOOST_THROW_EXCEPTION(invalid_argument("Invalid timestamp in command: " + line));
|
||||||
|
|
||||||
vector<String> argv = args.Split(is_any_of(";"));
|
vector<String> argv = args.Split(is_any_of(";"));
|
||||||
|
|
||||||
if (argv.size() == 0)
|
if (argv.size() == 0)
|
||||||
throw_exception(invalid_argument("Missing arguments in command: " + line));
|
BOOST_THROW_EXCEPTION(invalid_argument("Missing arguments in command: " + line));
|
||||||
|
|
||||||
vector<String> argvExtra(argv.begin() + 1, argv.end());
|
vector<String> argvExtra(argv.begin() + 1, argv.end());
|
||||||
Execute(ts, argv[0], argvExtra);
|
Execute(ts, argv[0], argvExtra);
|
||||||
|
@ -107,7 +107,7 @@ void ExternalCommandProcessor::Execute(double time, const String& command, const
|
||||||
it = m_Commands.find(command);
|
it = m_Commands.find(command);
|
||||||
|
|
||||||
if (it == m_Commands.end())
|
if (it == m_Commands.end())
|
||||||
throw_exception(invalid_argument("The external command '" + command + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The external command '" + command + "' does not exist."));
|
||||||
|
|
||||||
it->second(time, arguments);
|
it->second(time, arguments);
|
||||||
}
|
}
|
||||||
|
@ -120,15 +120,15 @@ void ExternalCommandProcessor::RegisterCommand(const String& command, const Exte
|
||||||
void ExternalCommandProcessor::ProcessServiceCheckResult(double time, const vector<String>& arguments)
|
void ExternalCommandProcessor::ProcessServiceCheckResult(double time, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 4)
|
if (arguments.size() < 4)
|
||||||
throw_exception(invalid_argument("Expected 4 arguments."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 4 arguments."));
|
||||||
|
|
||||||
if (!Service::Exists(arguments[1]))
|
if (!Service::Exists(arguments[1]))
|
||||||
throw_exception(invalid_argument("The service '" + arguments[1] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The service '" + arguments[1] + "' does not exist."));
|
||||||
|
|
||||||
Service::Ptr service = Service::GetByName(arguments[1]);
|
Service::Ptr service = Service::GetByName(arguments[1]);
|
||||||
|
|
||||||
if (!service->GetEnablePassiveChecks())
|
if (!service->GetEnablePassiveChecks())
|
||||||
throw_exception(invalid_argument("Got passive check result for service '" + arguments[1] + "' which has passive checks disabled."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Got passive check result for service '" + arguments[1] + "' which has passive checks disabled."));
|
||||||
|
|
||||||
int exitStatus = Convert::ToDouble(arguments[2]);
|
int exitStatus = Convert::ToDouble(arguments[2]);
|
||||||
Dictionary::Ptr result = PluginCheckTask::ParseCheckOutput(arguments[3]);
|
Dictionary::Ptr result = PluginCheckTask::ParseCheckOutput(arguments[3]);
|
||||||
|
@ -152,10 +152,10 @@ void ExternalCommandProcessor::ProcessServiceCheckResult(double time, const vect
|
||||||
void ExternalCommandProcessor::ScheduleSvcCheck(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::ScheduleSvcCheck(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 3)
|
if (arguments.size() < 3)
|
||||||
throw_exception(invalid_argument("Expected 3 arguments."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 3 arguments."));
|
||||||
|
|
||||||
if (!Service::Exists(arguments[1]))
|
if (!Service::Exists(arguments[1]))
|
||||||
throw_exception(invalid_argument("The service '" + arguments[1] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The service '" + arguments[1] + "' does not exist."));
|
||||||
|
|
||||||
Service::Ptr service = Service::GetByName(arguments[1]);
|
Service::Ptr service = Service::GetByName(arguments[1]);
|
||||||
|
|
||||||
|
@ -174,10 +174,10 @@ void ExternalCommandProcessor::ScheduleSvcCheck(double, const vector<String>& ar
|
||||||
void ExternalCommandProcessor::ScheduleForcedSvcCheck(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::ScheduleForcedSvcCheck(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 3)
|
if (arguments.size() < 3)
|
||||||
throw_exception(invalid_argument("Expected 3 arguments."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 3 arguments."));
|
||||||
|
|
||||||
if (!Service::Exists(arguments[1]))
|
if (!Service::Exists(arguments[1]))
|
||||||
throw_exception(invalid_argument("The service '" + arguments[1] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The service '" + arguments[1] + "' does not exist."));
|
||||||
|
|
||||||
Service::Ptr service = Service::GetByName(arguments[1]);
|
Service::Ptr service = Service::GetByName(arguments[1]);
|
||||||
|
|
||||||
|
@ -189,10 +189,10 @@ void ExternalCommandProcessor::ScheduleForcedSvcCheck(double, const vector<Strin
|
||||||
void ExternalCommandProcessor::EnableSvcCheck(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::EnableSvcCheck(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 2)
|
if (arguments.size() < 2)
|
||||||
throw_exception(invalid_argument("Expected 2 arguments."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 2 arguments."));
|
||||||
|
|
||||||
if (!Service::Exists(arguments[1]))
|
if (!Service::Exists(arguments[1]))
|
||||||
throw_exception(invalid_argument("The service '" + arguments[1] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The service '" + arguments[1] + "' does not exist."));
|
||||||
|
|
||||||
Service::Ptr service = Service::GetByName(arguments[1]);
|
Service::Ptr service = Service::GetByName(arguments[1]);
|
||||||
|
|
||||||
|
@ -203,10 +203,10 @@ void ExternalCommandProcessor::EnableSvcCheck(double, const vector<String>& argu
|
||||||
void ExternalCommandProcessor::DisableSvcCheck(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::DisableSvcCheck(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 2)
|
if (arguments.size() < 2)
|
||||||
throw_exception(invalid_argument("Expected 2 arguments."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 2 arguments."));
|
||||||
|
|
||||||
if (!Service::Exists(arguments[1]))
|
if (!Service::Exists(arguments[1]))
|
||||||
throw_exception(invalid_argument("The service '" + arguments[1] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The service '" + arguments[1] + "' does not exist."));
|
||||||
|
|
||||||
Service::Ptr service = Service::GetByName(arguments[1]);
|
Service::Ptr service = Service::GetByName(arguments[1]);
|
||||||
|
|
||||||
|
@ -223,10 +223,10 @@ void ExternalCommandProcessor::ShutdownProcess(double, const vector<String>&)
|
||||||
void ExternalCommandProcessor::ScheduleForcedHostSvcChecks(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::ScheduleForcedHostSvcChecks(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 2)
|
if (arguments.size() < 2)
|
||||||
throw_exception(invalid_argument("Expected 2 arguments."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 2 arguments."));
|
||||||
|
|
||||||
if (!Host::Exists(arguments[0]))
|
if (!Host::Exists(arguments[0]))
|
||||||
throw_exception(invalid_argument("The host '" + arguments[0] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The host '" + arguments[0] + "' does not exist."));
|
||||||
|
|
||||||
double planned_check = Convert::ToDouble(arguments[1]);
|
double planned_check = Convert::ToDouble(arguments[1]);
|
||||||
|
|
||||||
|
@ -242,10 +242,10 @@ void ExternalCommandProcessor::ScheduleForcedHostSvcChecks(double, const vector<
|
||||||
void ExternalCommandProcessor::ScheduleHostSvcChecks(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::ScheduleHostSvcChecks(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 2)
|
if (arguments.size() < 2)
|
||||||
throw_exception(invalid_argument("Expected 2 arguments."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 2 arguments."));
|
||||||
|
|
||||||
if (!Host::Exists(arguments[0]))
|
if (!Host::Exists(arguments[0]))
|
||||||
throw_exception(invalid_argument("The host '" + arguments[0] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The host '" + arguments[0] + "' does not exist."));
|
||||||
|
|
||||||
double planned_check = Convert::ToDouble(arguments[1]);
|
double planned_check = Convert::ToDouble(arguments[1]);
|
||||||
|
|
||||||
|
@ -266,10 +266,10 @@ void ExternalCommandProcessor::ScheduleHostSvcChecks(double, const vector<String
|
||||||
void ExternalCommandProcessor::EnableHostSvcChecks(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::EnableHostSvcChecks(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 1)
|
if (arguments.size() < 1)
|
||||||
throw_exception(invalid_argument("Expected 1 argument."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 1 argument."));
|
||||||
|
|
||||||
if (!Host::Exists(arguments[0]))
|
if (!Host::Exists(arguments[0]))
|
||||||
throw_exception(invalid_argument("The host '" + arguments[0] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The host '" + arguments[0] + "' does not exist."));
|
||||||
|
|
||||||
Host::Ptr host = Host::GetByName(arguments[0]);
|
Host::Ptr host = Host::GetByName(arguments[0]);
|
||||||
|
|
||||||
|
@ -282,10 +282,10 @@ void ExternalCommandProcessor::EnableHostSvcChecks(double, const vector<String>&
|
||||||
void ExternalCommandProcessor::DisableHostSvcChecks(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::DisableHostSvcChecks(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 1)
|
if (arguments.size() < 1)
|
||||||
throw_exception(invalid_argument("Expected 1 arguments."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 1 arguments."));
|
||||||
|
|
||||||
if (!Host::Exists(arguments[0]))
|
if (!Host::Exists(arguments[0]))
|
||||||
throw_exception(invalid_argument("The host '" + arguments[0] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The host '" + arguments[0] + "' does not exist."));
|
||||||
|
|
||||||
Host::Ptr host = Host::GetByName(arguments[0]);
|
Host::Ptr host = Host::GetByName(arguments[0]);
|
||||||
|
|
||||||
|
@ -298,17 +298,17 @@ void ExternalCommandProcessor::DisableHostSvcChecks(double, const vector<String>
|
||||||
void ExternalCommandProcessor::AcknowledgeSvcProblem(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::AcknowledgeSvcProblem(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 7)
|
if (arguments.size() < 7)
|
||||||
throw_exception(invalid_argument("Expected 7 arguments."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 7 arguments."));
|
||||||
|
|
||||||
if (!Service::Exists(arguments[1]))
|
if (!Service::Exists(arguments[1]))
|
||||||
throw_exception(invalid_argument("The service '" + arguments[1] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The service '" + arguments[1] + "' does not exist."));
|
||||||
|
|
||||||
bool sticky = Convert::ToBool(arguments[2]);
|
bool sticky = Convert::ToBool(arguments[2]);
|
||||||
|
|
||||||
Service::Ptr service = Service::GetByName(arguments[1]);
|
Service::Ptr service = Service::GetByName(arguments[1]);
|
||||||
|
|
||||||
if (service->GetState() == StateOK)
|
if (service->GetState() == StateOK)
|
||||||
throw_exception(invalid_argument("The service '" + arguments[1] + "' is OK."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The service '" + arguments[1] + "' is OK."));
|
||||||
|
|
||||||
Logger::Write(LogInformation, "icinga", "Setting acknowledgement for service '" + service->GetName() + "'");
|
Logger::Write(LogInformation, "icinga", "Setting acknowledgement for service '" + service->GetName() + "'");
|
||||||
service->SetAcknowledgement(sticky ? AcknowledgementSticky : AcknowledgementNormal);
|
service->SetAcknowledgement(sticky ? AcknowledgementSticky : AcknowledgementNormal);
|
||||||
|
@ -318,10 +318,10 @@ void ExternalCommandProcessor::AcknowledgeSvcProblem(double, const vector<String
|
||||||
void ExternalCommandProcessor::AcknowledgeSvcProblemExpire(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::AcknowledgeSvcProblemExpire(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 8)
|
if (arguments.size() < 8)
|
||||||
throw_exception(invalid_argument("Expected 8 arguments."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 8 arguments."));
|
||||||
|
|
||||||
if (!Service::Exists(arguments[1]))
|
if (!Service::Exists(arguments[1]))
|
||||||
throw_exception(invalid_argument("The service '" + arguments[1] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The service '" + arguments[1] + "' does not exist."));
|
||||||
|
|
||||||
bool sticky = Convert::ToBool(arguments[2]);
|
bool sticky = Convert::ToBool(arguments[2]);
|
||||||
double timestamp = Convert::ToDouble(arguments[5]);
|
double timestamp = Convert::ToDouble(arguments[5]);
|
||||||
|
@ -329,7 +329,7 @@ void ExternalCommandProcessor::AcknowledgeSvcProblemExpire(double, const vector<
|
||||||
Service::Ptr service = Service::GetByName(arguments[1]);
|
Service::Ptr service = Service::GetByName(arguments[1]);
|
||||||
|
|
||||||
if (service->GetState() == StateOK)
|
if (service->GetState() == StateOK)
|
||||||
throw_exception(invalid_argument("The service '" + arguments[1] + "' is OK."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The service '" + arguments[1] + "' is OK."));
|
||||||
|
|
||||||
Logger::Write(LogInformation, "icinga", "Setting timed acknowledgement for service '" + service->GetName() + "'");
|
Logger::Write(LogInformation, "icinga", "Setting timed acknowledgement for service '" + service->GetName() + "'");
|
||||||
service->SetAcknowledgement(sticky ? AcknowledgementSticky : AcknowledgementNormal);
|
service->SetAcknowledgement(sticky ? AcknowledgementSticky : AcknowledgementNormal);
|
||||||
|
@ -339,10 +339,10 @@ void ExternalCommandProcessor::AcknowledgeSvcProblemExpire(double, const vector<
|
||||||
void ExternalCommandProcessor::RemoveSvcAcknowledgement(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::RemoveSvcAcknowledgement(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 2)
|
if (arguments.size() < 2)
|
||||||
throw_exception(invalid_argument("Expected 2 arguments."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 2 arguments."));
|
||||||
|
|
||||||
if (!Service::Exists(arguments[1]))
|
if (!Service::Exists(arguments[1]))
|
||||||
throw_exception(invalid_argument("The service '" + arguments[1] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The service '" + arguments[1] + "' does not exist."));
|
||||||
|
|
||||||
Service::Ptr service = Service::GetByName(arguments[1]);
|
Service::Ptr service = Service::GetByName(arguments[1]);
|
||||||
|
|
||||||
|
@ -354,17 +354,17 @@ void ExternalCommandProcessor::RemoveSvcAcknowledgement(double, const vector<Str
|
||||||
void ExternalCommandProcessor::AcknowledgeHostProblem(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::AcknowledgeHostProblem(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 6)
|
if (arguments.size() < 6)
|
||||||
throw_exception(invalid_argument("Expected 6 arguments."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 6 arguments."));
|
||||||
|
|
||||||
if (!Host::Exists(arguments[0]))
|
if (!Host::Exists(arguments[0]))
|
||||||
throw_exception(invalid_argument("The host '" + arguments[0] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The host '" + arguments[0] + "' does not exist."));
|
||||||
|
|
||||||
bool sticky = Convert::ToBool(arguments[0]);
|
bool sticky = Convert::ToBool(arguments[0]);
|
||||||
|
|
||||||
Host::Ptr host = Host::GetByName(arguments[0]);
|
Host::Ptr host = Host::GetByName(arguments[0]);
|
||||||
|
|
||||||
if (host->IsUp())
|
if (host->IsUp())
|
||||||
throw_exception(invalid_argument("The host '" + arguments[0] + "' is OK."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The host '" + arguments[0] + "' is OK."));
|
||||||
|
|
||||||
Logger::Write(LogInformation, "icinga", "Setting acknowledgement for host '" + host->GetName() + "'");
|
Logger::Write(LogInformation, "icinga", "Setting acknowledgement for host '" + host->GetName() + "'");
|
||||||
host->SetAcknowledgement(sticky ? AcknowledgementSticky : AcknowledgementNormal);
|
host->SetAcknowledgement(sticky ? AcknowledgementSticky : AcknowledgementNormal);
|
||||||
|
@ -374,10 +374,10 @@ void ExternalCommandProcessor::AcknowledgeHostProblem(double, const vector<Strin
|
||||||
void ExternalCommandProcessor::AcknowledgeHostProblemExpire(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::AcknowledgeHostProblemExpire(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 7)
|
if (arguments.size() < 7)
|
||||||
throw_exception(invalid_argument("Expected 7 arguments."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 7 arguments."));
|
||||||
|
|
||||||
if (!Host::Exists(arguments[0]))
|
if (!Host::Exists(arguments[0]))
|
||||||
throw_exception(invalid_argument("The host '" + arguments[0] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The host '" + arguments[0] + "' does not exist."));
|
||||||
|
|
||||||
bool sticky = Convert::ToBool(arguments[1]);
|
bool sticky = Convert::ToBool(arguments[1]);
|
||||||
double timestamp = Convert::ToDouble(arguments[4]);
|
double timestamp = Convert::ToDouble(arguments[4]);
|
||||||
|
@ -385,7 +385,7 @@ void ExternalCommandProcessor::AcknowledgeHostProblemExpire(double, const vector
|
||||||
Host::Ptr host = Host::GetByName(arguments[0]);
|
Host::Ptr host = Host::GetByName(arguments[0]);
|
||||||
|
|
||||||
if (host->IsUp())
|
if (host->IsUp())
|
||||||
throw_exception(invalid_argument("The host '" + arguments[0] + "' is OK."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The host '" + arguments[0] + "' is OK."));
|
||||||
|
|
||||||
Logger::Write(LogInformation, "icinga", "Setting timed acknowledgement for host '" + host->GetName() + "'");
|
Logger::Write(LogInformation, "icinga", "Setting timed acknowledgement for host '" + host->GetName() + "'");
|
||||||
host->SetAcknowledgement(sticky ? AcknowledgementSticky : AcknowledgementNormal);
|
host->SetAcknowledgement(sticky ? AcknowledgementSticky : AcknowledgementNormal);
|
||||||
|
@ -395,10 +395,10 @@ void ExternalCommandProcessor::AcknowledgeHostProblemExpire(double, const vector
|
||||||
void ExternalCommandProcessor::RemoveHostAcknowledgement(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::RemoveHostAcknowledgement(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 1)
|
if (arguments.size() < 1)
|
||||||
throw_exception(invalid_argument("Expected 1 argument."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 1 argument."));
|
||||||
|
|
||||||
if (!Host::Exists(arguments[0]))
|
if (!Host::Exists(arguments[0]))
|
||||||
throw_exception(invalid_argument("The host '" + arguments[0] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The host '" + arguments[0] + "' does not exist."));
|
||||||
|
|
||||||
Host::Ptr host = Host::GetByName(arguments[0]);
|
Host::Ptr host = Host::GetByName(arguments[0]);
|
||||||
|
|
||||||
|
@ -410,10 +410,10 @@ void ExternalCommandProcessor::RemoveHostAcknowledgement(double, const vector<St
|
||||||
void ExternalCommandProcessor::EnableHostgroupSvcChecks(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::EnableHostgroupSvcChecks(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 1)
|
if (arguments.size() < 1)
|
||||||
throw_exception(invalid_argument("Expected 1 argument."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 1 argument."));
|
||||||
|
|
||||||
if (!HostGroup::Exists(arguments[0]))
|
if (!HostGroup::Exists(arguments[0]))
|
||||||
throw_exception(invalid_argument("The host group '" + arguments[0] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The host group '" + arguments[0] + "' does not exist."));
|
||||||
|
|
||||||
HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]);
|
HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]);
|
||||||
|
|
||||||
|
@ -428,10 +428,10 @@ void ExternalCommandProcessor::EnableHostgroupSvcChecks(double, const vector<Str
|
||||||
void ExternalCommandProcessor::DisableHostgroupSvcChecks(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::DisableHostgroupSvcChecks(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 1)
|
if (arguments.size() < 1)
|
||||||
throw_exception(invalid_argument("Expected 1 argument."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 1 argument."));
|
||||||
|
|
||||||
if (!HostGroup::Exists(arguments[0]))
|
if (!HostGroup::Exists(arguments[0]))
|
||||||
throw_exception(invalid_argument("The host group '" + arguments[0] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The host group '" + arguments[0] + "' does not exist."));
|
||||||
|
|
||||||
HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]);
|
HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]);
|
||||||
|
|
||||||
|
@ -446,10 +446,10 @@ void ExternalCommandProcessor::DisableHostgroupSvcChecks(double, const vector<St
|
||||||
void ExternalCommandProcessor::EnableServicegroupSvcChecks(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::EnableServicegroupSvcChecks(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 1)
|
if (arguments.size() < 1)
|
||||||
throw_exception(invalid_argument("Expected 1 argument."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 1 argument."));
|
||||||
|
|
||||||
if (!ServiceGroup::Exists(arguments[0]))
|
if (!ServiceGroup::Exists(arguments[0]))
|
||||||
throw_exception(invalid_argument("The service group '" + arguments[0] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The service group '" + arguments[0] + "' does not exist."));
|
||||||
|
|
||||||
ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]);
|
ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]);
|
||||||
|
|
||||||
|
@ -462,10 +462,10 @@ void ExternalCommandProcessor::EnableServicegroupSvcChecks(double, const vector<
|
||||||
void ExternalCommandProcessor::DisableServicegroupSvcChecks(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::DisableServicegroupSvcChecks(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 1)
|
if (arguments.size() < 1)
|
||||||
throw_exception(invalid_argument("Expected 1 argument."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 1 argument."));
|
||||||
|
|
||||||
if (!ServiceGroup::Exists(arguments[0]))
|
if (!ServiceGroup::Exists(arguments[0]))
|
||||||
throw_exception(invalid_argument("The service group '" + arguments[0] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The service group '" + arguments[0] + "' does not exist."));
|
||||||
|
|
||||||
ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]);
|
ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]);
|
||||||
|
|
||||||
|
@ -478,10 +478,10 @@ void ExternalCommandProcessor::DisableServicegroupSvcChecks(double, const vector
|
||||||
void ExternalCommandProcessor::EnablePassiveSvcChecks(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::EnablePassiveSvcChecks(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 2)
|
if (arguments.size() < 2)
|
||||||
throw_exception(invalid_argument("Expected 2 arguments."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 2 arguments."));
|
||||||
|
|
||||||
if (!Service::Exists(arguments[1]))
|
if (!Service::Exists(arguments[1]))
|
||||||
throw_exception(invalid_argument("The service '" + arguments[1] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The service '" + arguments[1] + "' does not exist."));
|
||||||
|
|
||||||
Service::Ptr service = Service::GetByName(arguments[1]);
|
Service::Ptr service = Service::GetByName(arguments[1]);
|
||||||
|
|
||||||
|
@ -492,10 +492,10 @@ void ExternalCommandProcessor::EnablePassiveSvcChecks(double, const vector<Strin
|
||||||
void ExternalCommandProcessor::DisablePassiveSvcChecks(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::DisablePassiveSvcChecks(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 2)
|
if (arguments.size() < 2)
|
||||||
throw_exception(invalid_argument("Expected 2 arguments."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 2 arguments."));
|
||||||
|
|
||||||
if (!Service::Exists(arguments[1]))
|
if (!Service::Exists(arguments[1]))
|
||||||
throw_exception(invalid_argument("The service '" + arguments[1] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The service '" + arguments[1] + "' does not exist."));
|
||||||
|
|
||||||
Service::Ptr service = Service::GetByName(arguments[1]);
|
Service::Ptr service = Service::GetByName(arguments[1]);
|
||||||
|
|
||||||
|
@ -506,10 +506,10 @@ void ExternalCommandProcessor::DisablePassiveSvcChecks(double, const vector<Stri
|
||||||
void ExternalCommandProcessor::EnableServicegroupPassiveSvcChecks(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::EnableServicegroupPassiveSvcChecks(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 1)
|
if (arguments.size() < 1)
|
||||||
throw_exception(invalid_argument("Expected 1 argument."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 1 argument."));
|
||||||
|
|
||||||
if (!ServiceGroup::Exists(arguments[0]))
|
if (!ServiceGroup::Exists(arguments[0]))
|
||||||
throw_exception(invalid_argument("The service group '" + arguments[0] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The service group '" + arguments[0] + "' does not exist."));
|
||||||
|
|
||||||
ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]);
|
ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]);
|
||||||
|
|
||||||
|
@ -522,10 +522,10 @@ void ExternalCommandProcessor::EnableServicegroupPassiveSvcChecks(double, const
|
||||||
void ExternalCommandProcessor::DisableServicegroupPassiveSvcChecks(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::DisableServicegroupPassiveSvcChecks(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 1)
|
if (arguments.size() < 1)
|
||||||
throw_exception(invalid_argument("Expected 1 argument."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 1 argument."));
|
||||||
|
|
||||||
if (!ServiceGroup::Exists(arguments[0]))
|
if (!ServiceGroup::Exists(arguments[0]))
|
||||||
throw_exception(invalid_argument("The service group '" + arguments[0] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The service group '" + arguments[0] + "' does not exist."));
|
||||||
|
|
||||||
ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]);
|
ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]);
|
||||||
|
|
||||||
|
@ -538,10 +538,10 @@ void ExternalCommandProcessor::DisableServicegroupPassiveSvcChecks(double, const
|
||||||
void ExternalCommandProcessor::EnableHostgroupPassiveSvcChecks(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::EnableHostgroupPassiveSvcChecks(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 1)
|
if (arguments.size() < 1)
|
||||||
throw_exception(invalid_argument("Expected 1 argument."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 1 argument."));
|
||||||
|
|
||||||
if (!HostGroup::Exists(arguments[0]))
|
if (!HostGroup::Exists(arguments[0]))
|
||||||
throw_exception(invalid_argument("The host group '" + arguments[0] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The host group '" + arguments[0] + "' does not exist."));
|
||||||
|
|
||||||
HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]);
|
HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]);
|
||||||
|
|
||||||
|
@ -556,10 +556,10 @@ void ExternalCommandProcessor::EnableHostgroupPassiveSvcChecks(double, const vec
|
||||||
void ExternalCommandProcessor::DisableHostgroupPassiveSvcChecks(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::DisableHostgroupPassiveSvcChecks(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 1)
|
if (arguments.size() < 1)
|
||||||
throw_exception(invalid_argument("Expected 1 argument."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 1 argument."));
|
||||||
|
|
||||||
if (!HostGroup::Exists(arguments[0]))
|
if (!HostGroup::Exists(arguments[0]))
|
||||||
throw_exception(invalid_argument("The host group '" + arguments[0] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The host group '" + arguments[0] + "' does not exist."));
|
||||||
|
|
||||||
HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]);
|
HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]);
|
||||||
|
|
||||||
|
@ -574,7 +574,7 @@ void ExternalCommandProcessor::DisableHostgroupPassiveSvcChecks(double, const ve
|
||||||
void ExternalCommandProcessor::ProcessFile(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::ProcessFile(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 2)
|
if (arguments.size() < 2)
|
||||||
throw_exception(invalid_argument("Expected 2 arguments."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 2 arguments."));
|
||||||
|
|
||||||
String file = arguments[0];
|
String file = arguments[0];
|
||||||
bool del = Convert::ToBool(arguments[1]);
|
bool del = Convert::ToBool(arguments[1]);
|
||||||
|
@ -594,7 +594,7 @@ void ExternalCommandProcessor::ProcessFile(double, const vector<String>& argumen
|
||||||
Execute(line);
|
Execute(line);
|
||||||
} catch (const exception& ex) {
|
} catch (const exception& ex) {
|
||||||
stringstream msgbuf;
|
stringstream msgbuf;
|
||||||
msgbuf << "External command failed: " << ex.what();
|
msgbuf << "External command failed: " << diagnostic_information(ex);
|
||||||
Logger::Write(LogWarning, "icinga", msgbuf.str());
|
Logger::Write(LogWarning, "icinga", msgbuf.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -608,10 +608,10 @@ void ExternalCommandProcessor::ProcessFile(double, const vector<String>& argumen
|
||||||
void ExternalCommandProcessor::ScheduleSvcDowntime(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::ScheduleSvcDowntime(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 9)
|
if (arguments.size() < 9)
|
||||||
throw_exception(invalid_argument("Expected 9 arguments."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 9 arguments."));
|
||||||
|
|
||||||
if (!Service::Exists(arguments[1]))
|
if (!Service::Exists(arguments[1]))
|
||||||
throw_exception(invalid_argument("The service '" + arguments[1] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The service '" + arguments[1] + "' does not exist."));
|
||||||
|
|
||||||
Service::Ptr service = Service::GetByName(arguments[1]);
|
Service::Ptr service = Service::GetByName(arguments[1]);
|
||||||
|
|
||||||
|
@ -629,7 +629,7 @@ void ExternalCommandProcessor::ScheduleSvcDowntime(double, const vector<String>&
|
||||||
void ExternalCommandProcessor::DelSvcDowntime(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::DelSvcDowntime(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 1)
|
if (arguments.size() < 1)
|
||||||
throw_exception(invalid_argument("Expected 1 argument."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 1 argument."));
|
||||||
|
|
||||||
int id = Convert::ToLong(arguments[0]);
|
int id = Convert::ToLong(arguments[0]);
|
||||||
Logger::Write(LogInformation, "icinga", "Removing downtime ID " + arguments[0]);
|
Logger::Write(LogInformation, "icinga", "Removing downtime ID " + arguments[0]);
|
||||||
|
@ -640,10 +640,10 @@ void ExternalCommandProcessor::DelSvcDowntime(double, const vector<String>& argu
|
||||||
void ExternalCommandProcessor::ScheduleHostDowntime(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::ScheduleHostDowntime(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 8)
|
if (arguments.size() < 8)
|
||||||
throw_exception(invalid_argument("Expected 8 arguments."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 8 arguments."));
|
||||||
|
|
||||||
if (!Host::Exists(arguments[0]))
|
if (!Host::Exists(arguments[0]))
|
||||||
throw_exception(invalid_argument("The host '" + arguments[0] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The host '" + arguments[0] + "' does not exist."));
|
||||||
|
|
||||||
Host::Ptr host = Host::GetByName(arguments[0]);
|
Host::Ptr host = Host::GetByName(arguments[0]);
|
||||||
|
|
||||||
|
@ -661,7 +661,7 @@ void ExternalCommandProcessor::ScheduleHostDowntime(double, const vector<String>
|
||||||
void ExternalCommandProcessor::DelHostDowntime(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::DelHostDowntime(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 1)
|
if (arguments.size() < 1)
|
||||||
throw_exception(invalid_argument("Expected 1 argument."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 1 argument."));
|
||||||
|
|
||||||
int id = Convert::ToLong(arguments[0]);
|
int id = Convert::ToLong(arguments[0]);
|
||||||
Logger::Write(LogInformation, "icinga", "Removing downtime ID " + arguments[0]);
|
Logger::Write(LogInformation, "icinga", "Removing downtime ID " + arguments[0]);
|
||||||
|
@ -672,10 +672,10 @@ void ExternalCommandProcessor::DelHostDowntime(double, const vector<String>& arg
|
||||||
void ExternalCommandProcessor::ScheduleHostSvcDowntime(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::ScheduleHostSvcDowntime(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 8)
|
if (arguments.size() < 8)
|
||||||
throw_exception(invalid_argument("Expected 8 argument."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 8 argument."));
|
||||||
|
|
||||||
if (!Host::Exists(arguments[0]))
|
if (!Host::Exists(arguments[0]))
|
||||||
throw_exception(invalid_argument("The host '" + arguments[0] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The host '" + arguments[0] + "' does not exist."));
|
||||||
|
|
||||||
Host::Ptr host = Host::GetByName(arguments[0]);
|
Host::Ptr host = Host::GetByName(arguments[0]);
|
||||||
|
|
||||||
|
@ -700,10 +700,10 @@ void ExternalCommandProcessor::ScheduleHostSvcDowntime(double, const vector<Stri
|
||||||
void ExternalCommandProcessor::ScheduleHostgroupHostDowntime(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::ScheduleHostgroupHostDowntime(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 8)
|
if (arguments.size() < 8)
|
||||||
throw_exception(invalid_argument("Expected 8 arguments."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 8 arguments."));
|
||||||
|
|
||||||
if (!HostGroup::Exists(arguments[0]))
|
if (!HostGroup::Exists(arguments[0]))
|
||||||
throw_exception(invalid_argument("The host group '" + arguments[0] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The host group '" + arguments[0] + "' does not exist."));
|
||||||
|
|
||||||
HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]);
|
HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]);
|
||||||
|
|
||||||
|
@ -723,10 +723,10 @@ void ExternalCommandProcessor::ScheduleHostgroupHostDowntime(double, const vecto
|
||||||
void ExternalCommandProcessor::ScheduleHostgroupSvcDowntime(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::ScheduleHostgroupSvcDowntime(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 8)
|
if (arguments.size() < 8)
|
||||||
throw_exception(invalid_argument("Expected 8 arguments."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 8 arguments."));
|
||||||
|
|
||||||
if (!HostGroup::Exists(arguments[0]))
|
if (!HostGroup::Exists(arguments[0]))
|
||||||
throw_exception(invalid_argument("The host group '" + arguments[0] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The host group '" + arguments[0] + "' does not exist."));
|
||||||
|
|
||||||
HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]);
|
HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]);
|
||||||
|
|
||||||
|
@ -758,10 +758,10 @@ void ExternalCommandProcessor::ScheduleHostgroupSvcDowntime(double, const vector
|
||||||
void ExternalCommandProcessor::ScheduleServicegroupHostDowntime(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::ScheduleServicegroupHostDowntime(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 8)
|
if (arguments.size() < 8)
|
||||||
throw_exception(invalid_argument("Expected 8 arguments."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 8 arguments."));
|
||||||
|
|
||||||
if (!ServiceGroup::Exists(arguments[0]))
|
if (!ServiceGroup::Exists(arguments[0]))
|
||||||
throw_exception(invalid_argument("The host group '" + arguments[0] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The host group '" + arguments[0] + "' does not exist."));
|
||||||
|
|
||||||
ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]);
|
ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]);
|
||||||
|
|
||||||
|
@ -791,10 +791,10 @@ void ExternalCommandProcessor::ScheduleServicegroupHostDowntime(double, const ve
|
||||||
void ExternalCommandProcessor::ScheduleServicegroupSvcDowntime(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::ScheduleServicegroupSvcDowntime(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 8)
|
if (arguments.size() < 8)
|
||||||
throw_exception(invalid_argument("Expected 8 arguments."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 8 arguments."));
|
||||||
|
|
||||||
if (!ServiceGroup::Exists(arguments[0]))
|
if (!ServiceGroup::Exists(arguments[0]))
|
||||||
throw_exception(invalid_argument("The host group '" + arguments[0] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The host group '" + arguments[0] + "' does not exist."));
|
||||||
|
|
||||||
ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]);
|
ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]);
|
||||||
|
|
||||||
|
@ -814,10 +814,10 @@ void ExternalCommandProcessor::ScheduleServicegroupSvcDowntime(double, const vec
|
||||||
void ExternalCommandProcessor::AddHostComment(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::AddHostComment(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 4)
|
if (arguments.size() < 4)
|
||||||
throw_exception(invalid_argument("Expected 4 arguments."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 4 arguments."));
|
||||||
|
|
||||||
if (!Host::Exists(arguments[0]))
|
if (!Host::Exists(arguments[0]))
|
||||||
throw_exception(invalid_argument("The host '" + arguments[0] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The host '" + arguments[0] + "' does not exist."));
|
||||||
|
|
||||||
Host::Ptr host = Host::GetByName(arguments[0]);
|
Host::Ptr host = Host::GetByName(arguments[0]);
|
||||||
|
|
||||||
|
@ -828,7 +828,7 @@ void ExternalCommandProcessor::AddHostComment(double, const vector<String>& argu
|
||||||
void ExternalCommandProcessor::DelHostComment(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::DelHostComment(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 1)
|
if (arguments.size() < 1)
|
||||||
throw_exception(invalid_argument("Expected 1 argument."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 1 argument."));
|
||||||
|
|
||||||
int id = Convert::ToLong(arguments[0]);
|
int id = Convert::ToLong(arguments[0]);
|
||||||
Logger::Write(LogInformation, "icinga", "Removing comment ID " + arguments[0]);
|
Logger::Write(LogInformation, "icinga", "Removing comment ID " + arguments[0]);
|
||||||
|
@ -839,10 +839,10 @@ void ExternalCommandProcessor::DelHostComment(double, const vector<String>& argu
|
||||||
void ExternalCommandProcessor::AddSvcComment(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::AddSvcComment(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 5)
|
if (arguments.size() < 5)
|
||||||
throw_exception(invalid_argument("Expected 5 arguments."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 5 arguments."));
|
||||||
|
|
||||||
if (!Service::Exists(arguments[1]))
|
if (!Service::Exists(arguments[1]))
|
||||||
throw_exception(invalid_argument("The service '" + arguments[1] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The service '" + arguments[1] + "' does not exist."));
|
||||||
|
|
||||||
Service::Ptr service = Service::GetByName(arguments[1]);
|
Service::Ptr service = Service::GetByName(arguments[1]);
|
||||||
|
|
||||||
|
@ -853,7 +853,7 @@ void ExternalCommandProcessor::AddSvcComment(double, const vector<String>& argum
|
||||||
void ExternalCommandProcessor::DelSvcComment(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::DelSvcComment(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 1)
|
if (arguments.size() < 1)
|
||||||
throw_exception(invalid_argument("Expected 1 argument."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 1 argument."));
|
||||||
|
|
||||||
int id = Convert::ToLong(arguments[0]);
|
int id = Convert::ToLong(arguments[0]);
|
||||||
Logger::Write(LogInformation, "icinga", "Removing comment ID " + arguments[0]);
|
Logger::Write(LogInformation, "icinga", "Removing comment ID " + arguments[0]);
|
||||||
|
@ -865,10 +865,10 @@ void ExternalCommandProcessor::DelSvcComment(double, const vector<String>& argum
|
||||||
void ExternalCommandProcessor::DelAllHostComments(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::DelAllHostComments(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 1)
|
if (arguments.size() < 1)
|
||||||
throw_exception(invalid_argument("Expected 1 argument."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 1 argument."));
|
||||||
|
|
||||||
if (!Host::Exists(arguments[0]))
|
if (!Host::Exists(arguments[0]))
|
||||||
throw_exception(invalid_argument("The host '" + arguments[0] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The host '" + arguments[0] + "' does not exist."));
|
||||||
|
|
||||||
Host::Ptr host = Host::GetByName(arguments[0]);
|
Host::Ptr host = Host::GetByName(arguments[0]);
|
||||||
|
|
||||||
|
@ -879,10 +879,10 @@ void ExternalCommandProcessor::DelAllHostComments(double, const vector<String>&
|
||||||
void ExternalCommandProcessor::DelAllSvcComments(double, const vector<String>& arguments)
|
void ExternalCommandProcessor::DelAllSvcComments(double, const vector<String>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 2)
|
if (arguments.size() < 2)
|
||||||
throw_exception(invalid_argument("Expected 2 arguments."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Expected 2 arguments."));
|
||||||
|
|
||||||
if (!Service::Exists(arguments[1]))
|
if (!Service::Exists(arguments[1]))
|
||||||
throw_exception(invalid_argument("The service '" + arguments[1] + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("The service '" + arguments[1] + "' does not exist."));
|
||||||
|
|
||||||
Service::Ptr service = Service::GetByName(arguments[1]);
|
Service::Ptr service = Service::GetByName(arguments[1]);
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ Host::Ptr Host::GetByName(const String& name)
|
||||||
DynamicObject::Ptr configObject = DynamicObject::GetObject("Host", name);
|
DynamicObject::Ptr configObject = DynamicObject::GetObject("Host", name);
|
||||||
|
|
||||||
if (!configObject)
|
if (!configObject)
|
||||||
throw_exception(invalid_argument("Host '" + name + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Host '" + name + "' does not exist."));
|
||||||
|
|
||||||
return dynamic_pointer_cast<Host>(configObject);
|
return dynamic_pointer_cast<Host>(configObject);
|
||||||
}
|
}
|
||||||
|
@ -270,7 +270,7 @@ void Host::ObjectCommittedHandler(const ConfigItem::Ptr& item)
|
||||||
|
|
||||||
CopyServiceAttributes(host, service, builder);
|
CopyServiceAttributes(host, service, builder);
|
||||||
} else {
|
} else {
|
||||||
throw_exception(invalid_argument("Service description must be either a string or a dictionary."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Service description must be either a string or a dictionary."));
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigItem::Ptr serviceItem = builder->Compile();
|
ConfigItem::Ptr serviceItem = builder->Compile();
|
||||||
|
@ -410,10 +410,10 @@ void Host::ValidateServicesCache(void)
|
||||||
void Host::ValidateServiceDictionary(const ScriptTask::Ptr& task, const vector<Value>& arguments)
|
void Host::ValidateServiceDictionary(const ScriptTask::Ptr& task, const vector<Value>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 1)
|
if (arguments.size() < 1)
|
||||||
throw_exception(invalid_argument("Missing argument: Location must be specified."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Missing argument: Location must be specified."));
|
||||||
|
|
||||||
if (arguments.size() < 2)
|
if (arguments.size() < 2)
|
||||||
throw_exception(invalid_argument("Missing argument: Attribute dictionary must be specified."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Missing argument: Attribute dictionary must be specified."));
|
||||||
|
|
||||||
String location = arguments[0];
|
String location = arguments[0];
|
||||||
Dictionary::Ptr attrs = arguments[1];
|
Dictionary::Ptr attrs = arguments[1];
|
||||||
|
|
|
@ -56,7 +56,7 @@ HostGroup::Ptr HostGroup::GetByName(const String& name)
|
||||||
DynamicObject::Ptr configObject = DynamicObject::GetObject("HostGroup", name);
|
DynamicObject::Ptr configObject = DynamicObject::GetObject("HostGroup", name);
|
||||||
|
|
||||||
if (!configObject)
|
if (!configObject)
|
||||||
throw_exception(invalid_argument("HostGroup '" + name + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("HostGroup '" + name + "' does not exist."));
|
||||||
|
|
||||||
return dynamic_pointer_cast<HostGroup>(configObject);
|
return dynamic_pointer_cast<HostGroup>(configObject);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ String MacroProcessor::ResolveMacros(const String& str, const vector<Dictionary:
|
||||||
pos_second = result.FindFirstOf("$", pos_first + 1);
|
pos_second = result.FindFirstOf("$", pos_first + 1);
|
||||||
|
|
||||||
if (pos_second == String::NPos)
|
if (pos_second == String::NPos)
|
||||||
throw_exception(runtime_error("Closing $ not found in macro format String."));
|
BOOST_THROW_EXCEPTION(runtime_error("Closing $ not found in macro format String."));
|
||||||
|
|
||||||
String name = result.SubStr(pos_first + 1, pos_second - pos_first - 1);
|
String name = result.SubStr(pos_first + 1, pos_second - pos_first - 1);
|
||||||
String value;
|
String value;
|
||||||
|
@ -51,7 +51,7 @@ String MacroProcessor::ResolveMacros(const String& str, const vector<Dictionary:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!resolved)
|
if (!resolved)
|
||||||
throw_exception(runtime_error("Macro '" + name + "' is not defined."));
|
BOOST_THROW_EXCEPTION(runtime_error("Macro '" + name + "' is not defined."));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -26,7 +26,7 @@ REGISTER_SCRIPTFUNCTION("native::NullCheck", &NullCheckTask::ScriptFunc);
|
||||||
void NullCheckTask::ScriptFunc(const ScriptTask::Ptr& task, const vector<Value>& arguments)
|
void NullCheckTask::ScriptFunc(const ScriptTask::Ptr& task, const vector<Value>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 1)
|
if (arguments.size() < 1)
|
||||||
throw_exception(invalid_argument("Missing argument: Service must be specified."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Missing argument: Service must be specified."));
|
||||||
|
|
||||||
Dictionary::Ptr cr = boost::make_shared<Dictionary>();
|
Dictionary::Ptr cr = boost::make_shared<Dictionary>();
|
||||||
cr->Set("state", StateUnknown);
|
cr->Set("state", StateUnknown);
|
||||||
|
|
|
@ -30,11 +30,11 @@ PluginCheckTask::PluginCheckTask(const ScriptTask::Ptr& task, const Process::Ptr
|
||||||
void PluginCheckTask::ScriptFunc(const ScriptTask::Ptr& task, const vector<Value>& arguments)
|
void PluginCheckTask::ScriptFunc(const ScriptTask::Ptr& task, const vector<Value>& arguments)
|
||||||
{
|
{
|
||||||
if (arguments.size() < 1)
|
if (arguments.size() < 1)
|
||||||
throw_exception(invalid_argument("Missing argument: Service must be specified."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Missing argument: Service must be specified."));
|
||||||
|
|
||||||
Value vservice = arguments[0];
|
Value vservice = arguments[0];
|
||||||
if (!vservice.IsObjectType<DynamicObject>())
|
if (!vservice.IsObjectType<DynamicObject>())
|
||||||
throw_exception(invalid_argument("Argument must be a config object."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Argument must be a config object."));
|
||||||
|
|
||||||
Service::Ptr service = static_cast<Service::Ptr>(vservice);
|
Service::Ptr service = static_cast<Service::Ptr>(vservice);
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ Service::Ptr Service::GetByName(const String& name)
|
||||||
DynamicObject::Ptr configObject = DynamicObject::GetObject("Service", name);
|
DynamicObject::Ptr configObject = DynamicObject::GetObject("Service", name);
|
||||||
|
|
||||||
if (!configObject)
|
if (!configObject)
|
||||||
throw_exception(invalid_argument("Service '" + name + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Service '" + name + "' does not exist."));
|
||||||
|
|
||||||
return dynamic_pointer_cast<Service>(configObject);
|
return dynamic_pointer_cast<Service>(configObject);
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ Host::Ptr Service::GetHost(void) const
|
||||||
String hostname = Get("host_name");
|
String hostname = Get("host_name");
|
||||||
|
|
||||||
if (hostname.IsEmpty())
|
if (hostname.IsEmpty())
|
||||||
throw_exception(runtime_error("Service object is missing the 'host_name' property."));
|
BOOST_THROW_EXCEPTION(runtime_error("Service object is missing the 'host_name' property."));
|
||||||
|
|
||||||
return Host::GetByName(hostname);
|
return Host::GetByName(hostname);
|
||||||
}
|
}
|
||||||
|
@ -290,7 +290,7 @@ double Service::GetNextCheck(void)
|
||||||
value = Get("next_check");
|
value = Get("next_check");
|
||||||
|
|
||||||
if (value.IsEmpty())
|
if (value.IsEmpty())
|
||||||
throw_exception(runtime_error("Failed to schedule next check."));
|
BOOST_THROW_EXCEPTION(runtime_error("Failed to schedule next check."));
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
@ -707,7 +707,7 @@ void Service::CheckCompletedHandler(const Dictionary::Ptr& scheduleInfo,
|
||||||
} catch (const exception& ex) {
|
} catch (const exception& ex) {
|
||||||
stringstream msgbuf;
|
stringstream msgbuf;
|
||||||
msgbuf << "Exception occured during check for service '"
|
msgbuf << "Exception occured during check for service '"
|
||||||
<< GetName() << "': " << ex.what();
|
<< GetName() << "': " << diagnostic_information(ex);
|
||||||
String message = msgbuf.str();
|
String message = msgbuf.str();
|
||||||
|
|
||||||
Logger::Write(LogWarning, "checker", message);
|
Logger::Write(LogWarning, "checker", message);
|
||||||
|
|
|
@ -56,7 +56,7 @@ ServiceGroup::Ptr ServiceGroup::GetByName(const String& name)
|
||||||
DynamicObject::Ptr configObject = DynamicObject::GetObject("ServiceGroup", name);
|
DynamicObject::Ptr configObject = DynamicObject::GetObject("ServiceGroup", name);
|
||||||
|
|
||||||
if (!configObject)
|
if (!configObject)
|
||||||
throw_exception(invalid_argument("ServiceGroup '" + name + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("ServiceGroup '" + name + "' does not exist."));
|
||||||
|
|
||||||
return dynamic_pointer_cast<ServiceGroup>(configObject);
|
return dynamic_pointer_cast<ServiceGroup>(configObject);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ TimePeriod::Ptr TimePeriod::GetByName(const String& name)
|
||||||
DynamicObject::Ptr configObject = DynamicObject::GetObject("TimePeriod", name);
|
DynamicObject::Ptr configObject = DynamicObject::GetObject("TimePeriod", name);
|
||||||
|
|
||||||
if (!configObject)
|
if (!configObject)
|
||||||
throw_exception(invalid_argument("TimePeriod '" + name + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("TimePeriod '" + name + "' does not exist."));
|
||||||
|
|
||||||
return dynamic_pointer_cast<TimePeriod>(configObject);
|
return dynamic_pointer_cast<TimePeriod>(configObject);
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ Endpoint::Ptr Endpoint::GetByName(const String& name)
|
||||||
DynamicObject::Ptr configObject = DynamicObject::GetObject("Endpoint", name);
|
DynamicObject::Ptr configObject = DynamicObject::GetObject("Endpoint", name);
|
||||||
|
|
||||||
if (!configObject)
|
if (!configObject)
|
||||||
throw_exception(invalid_argument("Endpoint '" + name + "' does not exist."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Endpoint '" + name + "' does not exist."));
|
||||||
|
|
||||||
return dynamic_pointer_cast<Endpoint>(configObject);
|
return dynamic_pointer_cast<Endpoint>(configObject);
|
||||||
}
|
}
|
||||||
|
@ -224,7 +224,7 @@ void Endpoint::UnregisterTopicHandler(const String& topic, const function<Endpoi
|
||||||
//m_TopicHandlers[method] -= callback;
|
//m_TopicHandlers[method] -= callback;
|
||||||
//UnregisterSubscription(method);
|
//UnregisterSubscription(method);
|
||||||
|
|
||||||
throw_exception(NotImplementedException());
|
BOOST_THROW_EXCEPTION(NotImplementedException());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Endpoint::OnAttributeChanged(const String& name, const Value& oldValue)
|
void Endpoint::OnAttributeChanged(const String& name, const Value& oldValue)
|
||||||
|
@ -324,7 +324,7 @@ void Endpoint::ClientClosedHandler(void)
|
||||||
GetClient()->CheckException();
|
GetClient()->CheckException();
|
||||||
} catch (const exception& ex) {
|
} catch (const exception& ex) {
|
||||||
stringstream message;
|
stringstream message;
|
||||||
message << "Error occured for JSON-RPC socket: Message=" << ex.what();
|
message << "Error occured for JSON-RPC socket: Message=" << diagnostic_information(ex);
|
||||||
|
|
||||||
Logger::Write(LogWarning, "jsonrpc", message.str());
|
Logger::Write(LogWarning, "jsonrpc", message.str());
|
||||||
}*/
|
}*/
|
||||||
|
|
|
@ -104,7 +104,7 @@ void EndpointManager::AddListener(const String& service)
|
||||||
shared_ptr<SSL_CTX> sslContext = GetSSLContext();
|
shared_ptr<SSL_CTX> sslContext = GetSSLContext();
|
||||||
|
|
||||||
if (!sslContext)
|
if (!sslContext)
|
||||||
throw_exception(logic_error("SSL context is required for AddListener()"));
|
BOOST_THROW_EXCEPTION(logic_error("SSL context is required for AddListener()"));
|
||||||
|
|
||||||
stringstream s;
|
stringstream s;
|
||||||
s << "Adding new listener: port " << service;
|
s << "Adding new listener: port " << service;
|
||||||
|
@ -131,7 +131,7 @@ void EndpointManager::AddConnection(const String& node, const String& service) {
|
||||||
shared_ptr<SSL_CTX> sslContext = GetSSLContext();
|
shared_ptr<SSL_CTX> sslContext = GetSSLContext();
|
||||||
|
|
||||||
if (!sslContext)
|
if (!sslContext)
|
||||||
throw_exception(logic_error("SSL context is required for AddConnection()"));
|
BOOST_THROW_EXCEPTION(logic_error("SSL context is required for AddConnection()"));
|
||||||
|
|
||||||
TcpSocket::Ptr client = boost::make_shared<TcpSocket>();
|
TcpSocket::Ptr client = boost::make_shared<TcpSocket>();
|
||||||
client->Connect(node, service);
|
client->Connect(node, service);
|
||||||
|
@ -229,7 +229,7 @@ void EndpointManager::SendAnycastMessage(const Endpoint::Ptr& sender,
|
||||||
{
|
{
|
||||||
String method;
|
String method;
|
||||||
if (!message.GetMethod(&method))
|
if (!message.GetMethod(&method))
|
||||||
throw_exception(invalid_argument("Message is missing the 'method' property."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Message is missing the 'method' property."));
|
||||||
|
|
||||||
vector<Endpoint::Ptr> candidates;
|
vector<Endpoint::Ptr> candidates;
|
||||||
DynamicObject::Ptr object;
|
DynamicObject::Ptr object;
|
||||||
|
@ -273,11 +273,11 @@ void EndpointManager::SendMulticastMessage(const Endpoint::Ptr& sender,
|
||||||
{
|
{
|
||||||
String id;
|
String id;
|
||||||
if (message.GetID(&id))
|
if (message.GetID(&id))
|
||||||
throw_exception(invalid_argument("Multicast requests must not have an ID."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Multicast requests must not have an ID."));
|
||||||
|
|
||||||
String method;
|
String method;
|
||||||
if (!message.GetMethod(&method))
|
if (!message.GetMethod(&method))
|
||||||
throw_exception(invalid_argument("Message is missing the 'method' property."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Message is missing the 'method' property."));
|
||||||
|
|
||||||
DynamicObject::Ptr object;
|
DynamicObject::Ptr object;
|
||||||
BOOST_FOREACH(tie(tuples::ignore, object), DynamicType::GetByName("Endpoint")->GetObjects()) {
|
BOOST_FOREACH(tie(tuples::ignore, object), DynamicType::GetByName("Endpoint")->GetObjects()) {
|
||||||
|
@ -391,7 +391,7 @@ void EndpointManager::ProcessResponseMessage(const Endpoint::Ptr& sender,
|
||||||
{
|
{
|
||||||
String id;
|
String id;
|
||||||
if (!message.GetID(&id))
|
if (!message.GetID(&id))
|
||||||
throw_exception(invalid_argument("Response message must have a message ID."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Response message must have a message ID."));
|
||||||
|
|
||||||
map<String, PendingRequest>::iterator it;
|
map<String, PendingRequest>::iterator it;
|
||||||
it = m_Requests.find(id);
|
it = m_Requests.find(id);
|
||||||
|
|
|
@ -57,7 +57,7 @@ void JsonRpcConnection::ProcessData(void)
|
||||||
Value value = Value::Deserialize(jsonString);
|
Value value = Value::Deserialize(jsonString);
|
||||||
|
|
||||||
if (!value.IsObjectType<Dictionary>()) {
|
if (!value.IsObjectType<Dictionary>()) {
|
||||||
throw_exception(invalid_argument("JSON-RPC"
|
BOOST_THROW_EXCEPTION(invalid_argument("JSON-RPC"
|
||||||
" message must be a dictionary."));
|
" message must be a dictionary."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ void JsonRpcConnection::ProcessData(void)
|
||||||
} catch (const exception& ex) {
|
} catch (const exception& ex) {
|
||||||
Logger::Write(LogCritical, "remoting", "Exception"
|
Logger::Write(LogCritical, "remoting", "Exception"
|
||||||
" while processing message from JSON-RPC client: " +
|
" while processing message from JSON-RPC client: " +
|
||||||
String(ex.what()));
|
diagnostic_information(ex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue