Get the FREE Ultimate OpenClaw Setup Guide →

error-patterns

Scanned
npx machina-cli add skill athola/claude-night-market/error-patterns --openclaw
Files (1)
SKILL.md
4.7 KB

Table of Contents

Error Patterns

Overview

Standardized error handling patterns for consistent, production-grade behavior across plugins. Provides error classification, recovery strategies, and debugging workflows.

When To Use

  • Building resilient integrations
  • Need consistent error handling
  • Want graceful degradation
  • Debugging production issues

When NOT To Use

  • Project doesn't use the leyline infrastructure patterns
  • Simple scripts without service architecture needs

Error Classification

By Severity

LevelActionExample
CriticalHalt, alertAuth failure, service down
ErrorRetry or secondary strategyRate limit, timeout
WarningLog, continuePartial results, deprecation
InfoLog onlyNon-blocking issues

By Recoverability

class ErrorCategory(Enum):
    TRANSIENT = "transient"      # Retry likely to succeed
    PERMANENT = "permanent"       # Retry won't help
    CONFIGURATION = "config"      # User action needed
    RESOURCE = "resource"         # Quota/limit issue

Verification: Run the command with --help flag to verify availability.

Quick Start

Standard Error Handler

from leyline.error_patterns import handle_error, ErrorCategory

try:
    result = service.execute(prompt)
except RateLimitError as e:
    return handle_error(e, ErrorCategory.RESOURCE, {
        "retry_after": e.retry_after,
        "service": "gemini"
    })
except AuthError as e:
    return handle_error(e, ErrorCategory.CONFIGURATION, {
        "action": "Run 'gemini auth login'"
    })

Verification: Run the command with --help flag to verify availability.

Error Result

@dataclass
class ErrorResult:
    category: ErrorCategory
    message: str
    recoverable: bool
    suggested_action: str
    metadata: dict

Verification: Run the command with --help flag to verify availability.

Common Patterns

Authentication Errors (401/403)

  • Verify credentials exist
  • Check token expiration
  • Validate permissions/scopes
  • Suggest re-authentication

Rate Limit Errors (429)

  • Extract retry-after header
  • Log for quota tracking
  • Implement backoff
  • Consider alternative service

Timeout Errors

  • Increase timeout for retries
  • Break into smaller requests
  • Use async patterns
  • Consider different model

Context Too Large (400)

  • Estimate tokens before request
  • Split into multiple requests
  • Reduce input content
  • Use larger context model

Integration Pattern

# In your skill's frontmatter
dependencies: [leyline:error-patterns]

Verification: Run the command with --help flag to verify availability.

Detailed Resources

  • Classification: See modules/classification.md for error taxonomy
  • Recovery: See modules/recovery-strategies.md for handling patterns
  • Agent Damage Control: See modules/agent-damage-control.md for multi-agent error recovery and escalation

Exit Criteria

  • Error classified correctly
  • Appropriate recovery attempted
  • User-actionable message provided
  • Error logged for debugging

Troubleshooting

Common Issues

Command not found Ensure all dependencies are installed and in PATH

Permission errors Check file permissions and run with appropriate privileges

Unexpected behavior Enable verbose logging with --verbose flag

Source

git clone https://github.com/athola/claude-night-market/blob/master/plugins/leyline/skills/error-patterns/SKILL.mdView on GitHub

Overview

Error Patterns provides standardized error handling patterns for consistent, production-grade behavior across plugins. It offers error classification, recovery strategies, and debugging workflows.

How This Skill Works

It classifies errors by severity and recoverability, then routes them through a standard handler that can perform retries, backoffs, or graceful degradation. Implementations use the ErrorResult structure and the Standard Error Handler to produce actionable metadata.

When to Use It

  • Building resilient integrations
  • Need consistent error handling across services
  • Want graceful degradation under stress
  • Debugging production issues with standardized logs
  • Aligning with leyline infrastructure patterns

Quick Start

  1. Step 1: Import handle_error and ErrorCategory from leyline.error_patterns
  2. Step 2: Wrap the risky call in try/except blocks (e.g., catch RateLimitError and AuthError) and route through handle_error
  3. Step 3: Verify availability with the recommended flag, e.g., run the command with --help as shown in quick-start snippets

Best Practices

  • Classify errors by severity and recoverability to guide handling
  • Use the standardized ErrorResult structure to convey metadata
  • Implement recovery strategies such as retries, backoff, and fallbacks
  • Centralize error logging and tracing with usage-logging
  • Validate errors with tests and integrate with the Standard Error Handler

Example Use Cases

  • Handling Rate Limit Errors (429) with retry-after logic and backoff
  • Handling Authentication Errors (401/403) by prompting re-authentication or a config action
  • Handling Timeout Errors by increasing timeouts and breaking requests into smaller parts
  • Handling Context Too Large (400) by estimating tokens and splitting requests
  • Using the Standard Error Handler in a plugin to surface errors consistently and provide actionable metadata

Frequently Asked Questions

Add this skill to your agents

Related Skills

Sponsor this space

Reach thousands of developers