b message parser

add try catch around command_parser and event_parser
This commit is contained in:
2024-08-27 13:23:02 +02:00
parent 35d36a675d
commit 6dca168b71
+16 -1
View File
@@ -23,10 +23,12 @@ std::string message_parser(std::string message)
}
json command_parser(json command)
{
json j;
try
{
std::string type = command["type"];
Command cmd = magic_enum::enum_cast<Command>(type).value_or(Command::end);
json j;
switch (cmd)
{
case Command::get_UI_element:
@@ -57,10 +59,18 @@ json command_parser(json command)
default:
break;
}
}
catch(const json::exception& e)
{
spdlog::error(e.what());
}
return j;
}
void event_handler(json event)
{
try
{
std::string type = event["type"];
Event e = magic_enum::enum_cast<Event>(type).value_or(Event::end);
@@ -102,3 +112,8 @@ void event_handler(json event)
}
}
}
catch(const json::exception& e)
{
spdlog::error(e.what());
}
}