From 7e7512a5555e271f76d48be19d1c0841a5ec3a96 Mon Sep 17 00:00:00 2001 From: Will Brown Date: Fri, 22 Nov 2024 23:57:56 -0500 Subject: [PATCH] [main.c] Add more logging --- main.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index e235120..328be2c 100644 --- a/main.c +++ b/main.c @@ -74,7 +74,7 @@ static void timer_retrieve_feeds(struct discord *client, struct discord_timer *t int nfeeds = PQntuples(database_res); zblock_feed_buffer *feed_list = malloc(nfeeds * sizeof(*feed_list)); if (!feed_list) { - // well there goes that idea + log_error("Unable to retrieve feed list: %s", strerror(errno)); PQclear(database_res); return; } @@ -89,6 +89,7 @@ static void timer_retrieve_feeds(struct discord *client, struct discord_timer *t CURLM *multi = curl_multi_init(); if (!multi) { // oh no + log_error("Unable to retrieve feed list: NULL pointer from curl_multi_init()"); goto all_done; } @@ -371,6 +372,8 @@ static void on_interaction(struct discord *client, const struct discord_interact } int main(void) { + int exit_code = 0; + srand(time(NULL)); struct discord *client = discord_config_init("config.json"); zblock_config_load(client); @@ -379,6 +382,7 @@ int main(void) { database_conn = PQconnectdb(zblock_config.conninfo); if (!database_conn) { log_fatal("Failed to connect to database."); + exit_code = 1; goto cleanup; } @@ -390,4 +394,6 @@ int main(void) { cleanup: discord_cleanup(client); ccord_global_cleanup(); + + return exit_code; }