refactor: try/catch around json parse

This commit is contained in:
Alex
2019-05-09 10:30:54 +02:00
parent fd9b34adf8
commit 5bf0ca85ac
6 changed files with 55 additions and 48 deletions

View File

@ -15,13 +15,17 @@ Mode::Mode(const std::string& id, const Json::Value& config) : ALabel(config, "{
}
void Mode::onEvent(const struct Ipc::ipc_response& res) {
auto payload = parser_.parse(res.payload);
if (payload["change"] != "default") {
mode_ = payload["change"].asString();
} else {
mode_.clear();
try {
auto payload = parser_.parse(res.payload);
if (payload["change"] != "default") {
mode_ = payload["change"].asString();
} else {
mode_.clear();
}
dp.emit();
} catch (const std::exception& e) {
std::cerr << "Mode: " << e.what() << std::endl;
}
dp.emit();
}
void Mode::worker() {