Catch exceptions when parsing invalid json
This commit is contained in:
@@ -384,16 +384,23 @@ void Executor::run()
|
||||
emit handleError(response);
|
||||
}
|
||||
}
|
||||
auto parsed = json::parse(
|
||||
response.toStdString().c_str(),
|
||||
nullptr,
|
||||
false
|
||||
);
|
||||
if (parsed.is_discarded() || parsed.is_null()) {
|
||||
try {
|
||||
auto parsed = json::parse(
|
||||
response.toStdString().c_str(),
|
||||
nullptr,
|
||||
false
|
||||
);
|
||||
|
||||
if (parsed.is_discarded() || parsed.is_null()) {
|
||||
emit handleError(response);
|
||||
} else {
|
||||
emit responseReady(parsed);
|
||||
}
|
||||
} catch (const std::exception& e) {
|
||||
DEBUG("exception when parsing json: " << e.what() );
|
||||
emit handleError(response);
|
||||
} else {
|
||||
emit responseReady(parsed);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Callback::processRPCCallback(json resp)
|
||||
|
||||
Reference in New Issue
Block a user