Report error objects

This commit is contained in:
blankie 2023-12-14 10:16:49 +11:00
parent 28473e489f
commit 12417d8f5e
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 2 additions and 1 deletions

View File

@ -278,7 +278,8 @@ nlohmann::json MastodonClient::_send_request(std::optional<std::string> cache_ke
long response_code = this->_response_status_code();
nlohmann::json j = nlohmann::json::parse(res);
if (response_code != 200) {
throw MastodonException(response_code, j.at("error").get<std::string>());
const nlohmann::json& error = j.at("error");
throw MastodonException(response_code, error.is_string() ? error.get<std::string>() : error.dump());
}
if (redis && cache_key) {