feat(errors): add shared error categorization and BatchResult primitives - #526
Open
Anthony-Bible wants to merge 3 commits into
Open
feat(errors): add shared error categorization and BatchResult primitives#526Anthony-Bible wants to merge 3 commits into
Anthony-Bible wants to merge 3 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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