Proper exit codes and error propagation #165

Open
opened 2026-10-07 12:00:55 +00:00 by aniram · 0 comments
Owner

Currently, when any sync fails, the code logs the error and returns from main, so the process exits 0. Cron, systemd, and CI can't tell that a sync failed. This also applies to the setup failures that only fmt.Printf.

Commands return error; main logs it and exits 1.
Wrap errors with context (fmt.Errorf("sync polls year=%d: %w", year, err)) so the year/legislature details currently passed as slog attributes aren't lost.
Log the final error to both stderr and the sync log file.

Acceptance criteria:

  • A forced failure (e.g. bad filename for session) exits non-zero.
  • A successful run exits 0.
Currently, when any sync fails, the code logs the error and returns from main, so the process exits 0. Cron, systemd, and CI can't tell that a sync failed. This also applies to the setup failures that only fmt.Printf. Commands return error; main logs it and exits 1. Wrap errors with context (fmt.Errorf("sync polls year=%d: %w", year, err)) so the year/legislature details currently passed as slog attributes aren't lost. Log the final error to both stderr and the sync log file. Acceptance criteria: - A forced failure (e.g. bad filename for session) exits non-zero. - A successful run exits 0.
aniram added this to the 2027.1 milestone 2026-10-07 12:00:55 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
overdrives/chambersbr#165
No description provided.