From 12417d8f5eab06e3daa6f44beb0bd2b9fc18ed0d Mon Sep 17 00:00:00 2001 From: blankie Date: Thu, 14 Dec 2023 10:16:49 +1100 Subject: [PATCH] Report error objects --- client.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client.cpp b/client.cpp index 2922e60..2f395ec 100644 --- a/client.cpp +++ b/client.cpp @@ -278,7 +278,8 @@ nlohmann::json MastodonClient::_send_request(std::optional 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()); + const nlohmann::json& error = j.at("error"); + throw MastodonException(response_code, error.is_string() ? error.get() : error.dump()); } if (redis && cache_key) {