From d7f83d4b46552b0d9729cf83212fdf12e389a6c7 Mon Sep 17 00:00:00 2001 From: Simon Quigley Date: Mon, 16 Dec 2024 21:23:26 -0600 Subject: [PATCH] Add enhanced debugging for missing endpoints --- src/launchpad.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/launchpad.cpp b/src/launchpad.cpp index 4d861ce..b77e557 100644 --- a/src/launchpad.cpp +++ b/src/launchpad.cpp @@ -220,7 +220,16 @@ std::string launchpad::build_full_url(const std::string& endpoint) const { std::optional launchpad::api_get(const std::string& endpoint, const std::map& params) const { std::string url = build_full_url(endpoint); - if (url.empty()) { return std::nullopt; } + if (url.empty()) { + std::cerr << "Internal error: please include the following info in a bug report:" << std::endl; + if (!params.empty()) { + for (const auto& [key, value] : params) { + std::cerr << url_encode(key) + "=" + url_encode(value) + "&"; + } + std::cerr << std::endl; + } + return std::nullopt; + } if (!params.empty()) { url += "?"; for (const auto& [key, value] : params) { @@ -292,8 +301,17 @@ std::optional launchpad::api_post( bool build_endpoint, const std::string& token_secret_override ) { + if (endpoint.empty()) { + std::cerr << "Internal error: please include the following info in a bug report:" << std::endl; + if (!params.empty()) { + for (const auto& [key, value] : params) { + std::cerr << url_encode(key) + "=" + url_encode(value) + "&"; + } + std::cerr << std::endl; + } + return std::nullopt; + } std::string url = build_endpoint ? build_full_url(endpoint) : endpoint; - if (url.empty()) { return std::nullopt; } CURL* curl = curl_easy_init(); if (!curl) {