error display

This commit is contained in:
Scott E. Graves 2025-02-18 16:12:23 -06:00
parent 249d6aa3eb
commit 9c30afe508

View File

@ -30,6 +30,8 @@ namespace monitarr {
static void remove_stalled(std::string_view download_id, std::string_view title, static void remove_stalled(std::string_view download_id, std::string_view title,
std::uint64_t episode_id, std::uint64_t movie_id, std::uint64_t episode_id, std::uint64_t movie_id,
const server_cfg &server, data_db &state_db) { const server_cfg &server, data_db &state_db) {
MONITARR_USES_FUNCTION_NAME();
fmt::println("remove and block {}|{}|{}|{}", server.id, server.url, title, fmt::println("remove and block {}|{}|{}|{}", server.id, server.url, title,
download_id); download_id);
state_db.remove(download_id); state_db.remove(download_id);
@ -40,8 +42,9 @@ static void remove_stalled(std::string_view download_id, std::string_view title,
server.api_version, server.api_version,
utils::string::split(download_id, '/', false).at(1U))); utils::string::split(download_id, '/', false).at(1U)));
if (response->status != httplib::StatusCode::OK_200) { if (response->status != httplib::StatusCode::OK_200) {
fmt::println("failed to delete download|{}|{}|{}", server.id, server.url, utils::error::handle_error(
response->status); function_name, fmt::format("failed to delete download|{}|{}|{}",
server.id, server.url, response->status));
return; return;
} }
@ -53,8 +56,10 @@ static void remove_stalled(std::string_view download_id, std::string_view title,
response = cli.Post("/api/{}/command", data.dump(), "application/json"); response = cli.Post("/api/{}/command", data.dump(), "application/json");
if (response->status != httplib::StatusCode::OK_200) { if (response->status != httplib::StatusCode::OK_200) {
fmt::println("failed to search radarr|{}|{}|{}|{}|{}", server.id, utils::error::handle_error(
server.url, title, movie_id, response->status); function_name,
fmt::format("failed to search radarr|{}|{}|{}|{}|{}", server.id,
server.url, title, movie_id, response->status));
} }
return; return;
} }
@ -67,14 +72,18 @@ static void remove_stalled(std::string_view download_id, std::string_view title,
response = cli.Post("/api/{}/command", data.dump(), "application/json"); response = cli.Post("/api/{}/command", data.dump(), "application/json");
if (response->status != httplib::StatusCode::OK_200) { if (response->status != httplib::StatusCode::OK_200) {
fmt::println("failed to search sonarr|{}|{}|{}|{}|{}", server.id, utils::error::handle_error(
server.url, title, episode_id, response->status); function_name,
fmt::format("failed to search sonarr|{}|{}|{}|{}|{}", server.id,
server.url, title, episode_id, response->status));
} }
return; return;
} }
} }
static void check_server(const server_cfg &server, data_db &state_db) { static void check_server(const server_cfg &server, data_db &state_db) {
MONITARR_USES_FUNCTION_NAME();
fmt::println("checking server|{}|{}", server.id, server.url); fmt::println("checking server|{}|{}", server.id, server.url);
auto cli = create_client(server); auto cli = create_client(server);
@ -88,8 +97,9 @@ static void check_server(const server_cfg &server, data_db &state_db) {
auto response = auto response =
cli.Get(fmt::format("/api/{}/queue", server.api_version), params, {}); cli.Get(fmt::format("/api/{}/queue", server.api_version), params, {});
if (response->status != httplib::StatusCode::OK_200) { if (response->status != httplib::StatusCode::OK_200) {
fmt::println("check server request failed|{}|{}|{}", server.id, utils::error::handle_error(
server.url, response->status); function_name, fmt::format("check server request failed|{}|{}|{}",
server.id, server.url, response->status));
break; break;
} }
@ -227,7 +237,8 @@ auto main(int /* argc */, char ** /* argv */) -> int {
auto state_db{load_db()}; auto state_db{load_db()};
if (cfg.server_list.empty()) { if (cfg.server_list.empty()) {
fmt::println("no servers have been configured"); utils::error::handle_error(function_name,
"no servers have been configured");
ret = 3; ret = 3;
} else { } else {
while (not stop_requested) { while (not stop_requested) {