Skip to content

fix: log discarded errors across post/upcoming/shows - #46

Open
SpackledJim wants to merge 1 commit into
cbackas:mainfrom
SpackledJim:fix/log-swallowed-errors
Open

SpackledJim wants to merge 1 commit into
cbackas:mainfrom
SpackledJim:fix/log-swallowed-errors

Conversation

@SpackledJim

Copy link
Copy Markdown

Log errors in catch blocks that currently discard them

Commit: b810a7a — fix: log discarded errors across post/upcoming/shows

Context

A /post failure replied only Error creating posts for \tt4158110`, with nothing in the logs. The cause was a missing "Manage Messages" permission, which createForumPost` needs to pin the post. The thread was created before the pin failed, so the show was never saved to the DB, and a retry created a second thread.

A review of the codebase's catch blocks found three more that drop error details. Most other catch blocks (tvdb.ts, commandManager.ts, episodeNotifier.ts, link.ts) already log errors; these changes follow the same pattern.

Changes

File Location Before After
commands/post.ts per-show post creation error not logged console.error with IMDB ID
commands/upcoming.ts show lookup not logged; non-Error values fell through to "No shows found" logged; always replies with a message
lib/shows.ts getAirDate original error replaced by generic message logs error and input values, then rethrows
lib/shows.ts checkForAiringEpisodes logged a message but not the error object passes the error to console.error

User-facing messages are unchanged, except in upcoming.ts where non-Error values now return a generic error message instead of "No shows found".

Possible follow-up

Handle pin failures separately in createForumPost, so a post that was created successfully isn't treated as a failure.

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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S9oMx1pYL6igWuytQyqSTa

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant