From cbd459b0a5a7ff0003a364eb3b06b204bfc78128 Mon Sep 17 00:00:00 2001 From: WarmUpTill Date: Sat, 9 Sep 2023 01:38:35 +0200 Subject: [PATCH] Improve error logging --- src/macro-external/twitch/twitch-helpers.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/macro-external/twitch/twitch-helpers.cpp b/src/macro-external/twitch/twitch-helpers.cpp index 7bff5573..6ed0f6fd 100644 --- a/src/macro-external/twitch/twitch-helpers.cpp +++ b/src/macro-external/twitch/twitch-helpers.cpp @@ -20,6 +20,12 @@ RequestResult SendGetRequest(const std::string &uri, const std::string &path, httplib::Client cli(uri); auto headers = getTokenRequestHeaders(token); auto response = cli.Get(path, params, headers); + if (!response) { + auto err = response.error(); + blog(LOG_INFO, "%s failed - %s", __func__, + httplib::to_string(err).c_str()); + return {}; + } RequestResult result; result.status = response->status; if (response->body.empty()) { @@ -39,6 +45,12 @@ RequestResult SendPostRequest(const std::string &uri, const std::string &path, auto json = obs_data_get_json(data); std::string body = json ? json : ""; auto response = cli.Post(path, headers, body, "application/json"); + if (!response) { + auto err = response.error(); + blog(LOG_INFO, "%s failed - %s", __func__, + httplib::to_string(err).c_str()); + return {}; + } RequestResult result; result.status = response->status; if (response->body.empty()) { @@ -58,6 +70,12 @@ RequestResult SendPatchRequest(const std::string &uri, const std::string &path, auto json = obs_data_get_json(data); std::string body = json ? json : ""; auto response = cli.Patch(path, headers, body, "application/json"); + if (!response) { + auto err = response.error(); + blog(LOG_INFO, "%s failed - %s", __func__, + httplib::to_string(err).c_str()); + return {}; + } RequestResult result; result.status = response->status; if (response->body.empty()) {