fix std::get error on invalid query
This commit is contained in:
parent
467f107809
commit
377383d5a0
|
@ -76,10 +76,10 @@ private:
|
||||||
|
|
||||||
glz::json_t json{};
|
glz::json_t json{};
|
||||||
auto ec = glz::read_json(json, response.text);
|
auto ec = glz::read_json(json, response.text);
|
||||||
if (ec != glz::error_code::missing_key) {
|
if (ec != glz::error_code::parse_error && json["queryresult"]["success"].get_boolean()) {
|
||||||
return json["queryresult"]["pods"][1]["subpods"][0]["plaintext"].get<std::string>();
|
return json["queryresult"]["pods"][1]["subpods"][0]["plaintext"].get<std::string>();
|
||||||
} else {
|
} else {
|
||||||
throw std::invalid_argument("JSON Key not found");
|
throw std::invalid_argument("WolframAlpha query failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue