#include <settingsd/registrar.hpp>
#include <settingsd/event_callback.hpp>
-#include <stdexcept>
+#include <system_error>
#include <dlfcn.h>
: handle_(dlopen(plugin_name.c_str(), RTLD_LAZY | RTLD_GLOBAL))
{
if (handle_ == nullptr) {
- throw std::logic_error(dlerror());
+ throw std::system_error(std::error_code(), dlerror());
}
// Reset any lingering dynamic linking related errors (see
"register_settings"));
if (register_settings == nullptr)
- throw std::logic_error(dlerror());
+ throw std::system_error(std::error_code(), dlerror());
// Now create the underlying settings implementation.
ivi::settings::manager::load_settings(std::string const & dir)
{
if (dir.length() == 0)
- throw std::runtime_error("Zero length settings plugin "
- "directory path.");
+ throw std::invalid_argument("Zero length settings plugin "
+ "directory path.");
namespace fs = boost::filesystem;
loaders_.push_back(std::move(plugin));
}
- catch (std::logic_error & e) {
+ catch (std::exception & e) {
/**
* @todo I really hate catching an exception like this, but I
* really don't want to resort to a construct/init()
*/
std::cerr << "Error loading plugin: " << e.what() << "\n";
}
+ catch (...) {
+ std::cerr << "Ignoring unknown exception thrown from plugin.\n";
+ }
}
if (settings_.size() == 0) {
- throw std::runtime_error("Settings plugin directory \""
- + dir + "\" has no plugins.");
+ throw std::invalid_argument("Settings plugin directory \""
+ + dir + "\" has no plugins.");
} else {
- std::cerr << "Registered settings plugins: \n";
+ std::cerr << "Registered settings plugins:\n";
for (auto const & i : settings_)
std::cerr << "\t" << i.first << '\n';
}
} else {
- throw std::runtime_error("Settings plugin directory \""
- + dir + "\" does not exist.");
+ throw std::invalid_argument("Settings plugin directory \""
+ + dir + "\" does not exist.");
}
}
unique_ptr<JsonParser> const parser(json_parser_new());
json_parser_load_from_data(parser.get(), request.c_str(), -1, nullptr);
- JsonReader * const reader = json_reader_new(json_parser_get_root(parser.get()));
+ JsonReader * const reader =
+ json_reader_new(json_parser_get_root(parser.get()));
unique_ptr<JsonReader> const safe_reader(reader);
// Retrieve setting name and transcation ID from the JSON request
#include "../lib/config.hpp"
#include "../lib/manager.hpp"
-#include <stdexcept>
+#include <system_error>
context_ = libwebsocket_create_context(&info);
if (context_ == nullptr)
- throw std::runtime_error("Unable to initialize websocket.");
+ throw std::system_error(errno,
+ std::system_category(),
+ "Unable to initialize websocket.");
std::cout << "\n" PACKAGE_NAME " listening for requests on port "
<< info.port << ".\n";