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