Enhanced Error Handling and Retry Logic #31

Closed
opened 2026-02-13 18:35:26 +03:00 by NiXTheDev · 1 comment
NiXTheDev commented 2026-02-13 18:35:26 +03:00 (Migrated from github.com)

Improve error handling with granular error types and smarter retry logic.

Current Issues

  1. Generic error handling - hard to distinguish error types
  2. Retry logic is basic (auto-retry plugin)
  3. No exponential backoff with jitter
  4. Error messages not user-friendly
  5. Some errors not properly logged with context

Implementation

  1. Create custom error hierarchy:

    • BotError (base)
    • RegexError (invalid regex)
    • TelegramAPIError (API failures)
    • RateLimitError (user rate limited)
    • WorkerError (worker pool issues)
  2. Implement smart retry with:

    • Exponential backoff
    • Jitter to prevent thundering herd
    • Per-error-type retry policies
    • Circuit breaker pattern for persistent failures
  3. Improve user-facing error messages:

    • Clear, actionable messages
    • Context about what went wrong
    • Suggestions for fixing
  4. Add error aggregation and alerting

Testing

  • Unit tests for each error type
  • Retry logic tests with mock failures
  • Circuit breaker tests
  • Error message clarity tests
Improve error handling with granular error types and smarter retry logic. ## Current Issues 1. Generic error handling - hard to distinguish error types 2. Retry logic is basic (auto-retry plugin) 3. No exponential backoff with jitter 4. Error messages not user-friendly 5. Some errors not properly logged with context ## Implementation 1. Create custom error hierarchy: - BotError (base) - RegexError (invalid regex) - TelegramAPIError (API failures) - RateLimitError (user rate limited) - WorkerError (worker pool issues) 2. Implement smart retry with: - Exponential backoff - Jitter to prevent thundering herd - Per-error-type retry policies - Circuit breaker pattern for persistent failures 3. Improve user-facing error messages: - Clear, actionable messages - Context about what went wrong - Suggestions for fixing 4. Add error aggregation and alerting ## Testing - Unit tests for each error type - Retry logic tests with mock failures - Circuit breaker tests - Error message clarity tests
NiXTheDev commented 2026-02-13 19:06:04 +03:00 (Migrated from github.com)
  1. No exponential backoff with jitter

Handled by auto-retry plugin, it handles all network related errors(i.e. 429, 5xx, timeouts and alike)

  • RateLimitError (user rate limited)

Can be downgraded to a warn, or more likely debug, just a notice that the user is rate-limited and attempted to submit more sed commands, not critical

  1. Add error aggregation and alerting

Will require external service connection and configuration, for ex. gotify
Infra-less services like WirePusher and Ntfy do exist, but i'm skeptical about them

> 3. No exponential backoff with jitter Handled by auto-retry plugin, it handles all network related errors(i.e. 429, 5xx, timeouts and alike) > - RateLimitError (user rate limited) Can be downgraded to a warn, or more likely debug, just a notice that the user is rate-limited and attempted to submit more sed commands, not critical > 4. Add error aggregation and alerting Will require external service connection and configuration, for ex. gotify Infra-less services like WirePusher and Ntfy do exist, but i'm skeptical about them
Sign in to join this conversation.
No description provided.