From feb8a6bf5dafe6b59dc240498348bff255f0c7d9 Mon Sep 17 00:00:00 2001 From: SpackledJim Date: Mon, 28 Sep 2026 04:29:44 +0000 Subject: [PATCH] fix: log discarded errors across post/upcoming/shows Several catch blocks discarded the underlying error entirely, or only logged a string with no way to see what actually failed: - post.ts: forum post creation failures inside the per-show loop were silently discarded, with no way to diagnose real causes (permissions, rate limits). Added logging of the underlying error. - upcoming.ts: errors were only surfaced if they were an Error instance; anything else fell through silently to a misleading "No shows found" reply, and nothing was ever logged. Now logs the error and always replies with a message. - shows.ts (getAirDate): a date-parsing failure was replaced with a generic "Could not parse air date" message, discarding the original error and the actual date/time/timezone values involved. Now logs both before rethrowing. - shows.ts (checkForAiringEpisodes): the catch block looked like it logged the error, but only passed a string template to console.error and never included the actual error object/stack. Now logs it. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01S9oMx1pYL6igWuytQyqSTa --- src/commands/post.ts | 1 + src/commands/upcoming.ts | 8 +++++--- src/lib/shows.ts | 6 +++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/commands/post.ts b/src/commands/post.ts index 352b0e2..f4f54f0 100644 --- a/src/commands/post.ts +++ b/src/commands/post.ts @@ -131,6 +131,7 @@ export const command: CommandV2 = { post: newPost, }) } catch (error) { + console.error(`Error creating post for ${imdbId}:`, error) messages.push(`Error creating post for \`${imdbId}\``) seriesList.delete(imdbId) } diff --git a/src/commands/upcoming.ts b/src/commands/upcoming.ts index 3616c8e..a57f097 100644 --- a/src/commands/upcoming.ts +++ b/src/commands/upcoming.ts @@ -60,9 +60,11 @@ export const command: CommandV2 = { break } } catch (error) { - if (error instanceof Error) { - return await interaction.editReply(error.message) - } + console.error(`Error fetching upcoming episodes (${subCommand}):`, error) + const message = error instanceof Error + ? error.message + : "An unexpected error occurred while fetching upcoming episodes" + return await interaction.editReply(message) } if (s == null || s.length === 0) { diff --git a/src/lib/shows.ts b/src/lib/shows.ts index ad5766d..acbfbf6 100644 --- a/src/lib/shows.ts +++ b/src/lib/shows.ts @@ -28,6 +28,10 @@ function getAirDate( timezone, ) } catch (error) { + console.error( + `Could not parse air date (dateStr=${dateStr}, timeStr=${timeStr}, timezone=${timezone}):`, + error, + ) throw new Error("Could not parse air date") } } @@ -114,7 +118,7 @@ export async function checkForAiringEpisodes(): Promise { try { await updateEpisodes(show.imdbId, show.tvdbId) } catch (error) { - console.error(`Error updating episodes for ${show.name} (${show.imdbId})`) + console.error(`Error updating episodes for ${show.name} (${show.imdbId}):`, error) } }