Skip to content

feat(errors): add shared error categorization and BatchResult primitives - #526

Open
Anthony-Bible wants to merge 3 commits into
masterfrom
claude/exciting-davinci-UFy3f
Open

feat(errors): add shared error categorization and BatchResult primitives#526
Anthony-Bible wants to merge 3 commits into
masterfrom
claude/exciting-davinci-UFy3f

Conversation

@Anthony-Bible

Copy link
Copy Markdown
Owner

Introduces internal/shared/errors and internal/shared/batch as the foundation for issue #371. Errors can now be tagged with Fatal / Operational / Business categories that propagate through the standard fmt.Errorf %w chain, and IsRetryable centralizes the retry decision.

Wires the new primitives into the reminder pipeline:

  • Notification domain sentinels are categorized in errors.go.
  • ProcessReminders returns (*batch.BatchResult, error) so callers can see per-item outcomes instead of inferring partial success from logs.
  • retryWithBackoff short-circuits on non-retryable errors and no longer trips the circuit breaker on Business/Fatal failures.
  • cmd/reminder logs the structured BatchResult counts.

Out of scope for this PR (deferred to follow-up issues): wrapping cleanup in encryption/storage/message domains, metrics + dashboards, and rollout of the retry helper to other domains.

Refs #371

claude added 3 commits June 4, 2026 12:44
Introduces internal/shared/errors and internal/shared/batch as the
foundation for issue #371. Errors can now be tagged with Fatal /
Operational / Business categories that propagate through the standard
fmt.Errorf %w chain, and IsRetryable centralizes the retry decision.

Wires the new primitives into the reminder pipeline:
- Notification domain sentinels are categorized in errors.go.
- ProcessReminders returns (*batch.BatchResult, error) so callers can
  see per-item outcomes instead of inferring partial success from logs.
- retryWithBackoff short-circuits on non-retryable errors and no longer
  trips the circuit breaker on Business/Fatal failures.
- cmd/reminder logs the structured BatchResult counts.

Out of scope for this PR (deferred to follow-up issues): wrapping
cleanup in encryption/storage/message domains, metrics + dashboards,
and rollout of the retry helper to other domains.

Refs #371
…egorization

Reverts the premature shared/errors and shared/batch packages from the
previous commit. There is only one batch processor in the app today
(reminder cronjob), so categorization machinery and a generic
BatchResult are abstractions without a second consumer.

- Moves BatchResult into notification/domain/batch_result.go with a
  HasInfraFailures() check used by the cronjob for alerting.
- Replaces the Category type / IsRetryable helper with a small list of
  non-retryable sentinels checked via errors.Is in retryWithBackoff.
- Reverts notification sentinels in errors.go to plain errors.New.
- Updates CLAUDE.md to describe the local pattern rather than a shared
  one. Promote to a shared package only when a second consumer appears.

The behavior (fail-fast on validation errors, structured per-item
result for the cronjob) is preserved.
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.

2 participants