Catch exceptions when parsing invalid json

This commit is contained in:
Duke
2023-03-26 10:08:44 -07:00
parent 7e54360b72
commit b84828604f

View File

@@ -384,16 +384,23 @@ void Executor::run()
emit handleError(response); emit handleError(response);
} }
} }
try {
auto parsed = json::parse( auto parsed = json::parse(
response.toStdString().c_str(), response.toStdString().c_str(),
nullptr, nullptr,
false false
); );
if (parsed.is_discarded() || parsed.is_null()) { if (parsed.is_discarded() || parsed.is_null()) {
emit handleError(response); emit handleError(response);
} else { } else {
emit responseReady(parsed); emit responseReady(parsed);
} }
} catch (const std::exception& e) {
DEBUG("exception when parsing json: " << e.what() );
emit handleError(response);
}
} }
void Callback::processRPCCallback(json resp) void Callback::processRPCCallback(json resp)