Xpersona
E

error-patterns

CLAWHUB · Unverified

Provides error classification, recovery, and graceful-degradation patterns Skill: error-patterns Owner: athola Summary: Provides error classification, recovery, and graceful-degradation patterns Tags: latest:1.9.19 Version history: v1.9.19 | 2026-08-26T13:14:34.291Z | user Release v1.9.19 v1.9.17 | 2026-07-30T05:35:38.397Z | user Release v1.9.17 v1.9.16 | 2026-07-14T19:52:19.432Z | user Release v1.9.16 v1.9.14 | 2026-06-30T18:01:19.534Z | user Release v1.9.14 v1.9.13 | 2026-06-27T16:19:45.1

62
Rank
84
Safety
1.6k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.6K downloads reported by the source. Last updated 10/10/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s17emme0e2m3cpf7k2jvp3a84984b8z9:nm-leyline-error-patterns
  1. Setup complexity is classified as HIGH. You must provision dedicated cloud infrastructure or an isolated VM. Do not run this directly on your local workstation.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-athola-nm-leyline-error-patterns/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

145,341 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
name: error-patterns
description: Provides error classification, recovery, and graceful-degradation patterns
version: 1.9.8
triggers:
  - errors
  - error-handling
  - recovery
  - resilience
  - debugging
  - implementing error handling or debugging resilience failures in any skill
metadata: {"openclaw": {"homepage": "https://github.com/athola/claude-night-market/tree/master/plugins/leyline", "emoji": "\ud83e\udd9e", "requires": {"config": ["night-market.usage-logging"]}}}
source: claude-night-market
source_plugin: leyline
---

> **Night Market Skill** — ported from [claude-night-market/leyline](https://github.com/athola/claude-night-market/tree/master/plugins/leyline). For the full experience with agents, hooks, and commands, install the Claude Code plugin.


## Table of Contents

- [Overview](#overview)
- [When to Use](#when-to-use)
- [Error Classification](#error-classification)
- [By Severity](#by-severity)
- [By Recoverability](#by-recoverability)
- [Quick Start](#quick-start)
- [Standard Error Handler](#standard-error-handler)
- [Error Result](#error-result)
- [Common Patterns](#common-patterns)
- [Authentication Errors (401/403)](#authentication-errors-(401-403))
- [Rate Limit Errors (429)](#rate-limit-errors-(429))
- [Timeout Errors](#timeout-errors)
- [Context Too Large (400)](#context-too-large-(400))
- [Integration Pattern](#integration-pattern)
- [Detailed Resources](#detailed-resources)
- [Exit Criteria](#exit-criteria)


# 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

| Level | Action | Example |
|-------|--------|---------|
| **Critical** | Halt, alert | Auth failure, service down |
| **Error** | Retry or secondary strategy | Rate limit, timeout |
| **Warning** | Log, continue | Partial results, deprecation |
| **Info** | Log only | Non-blocking issues |

### By Recoverability

```python
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
```python
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(

_meta.json

{
  "ownerId": "kn7d107jg9jv602h9ytsegydq184a42s",
  "slug": "nm-leyline-error-patterns",
  "version": "1.9.19",
  "publishedAt": 1787750074291
}

modules/agent-damage-control.md

# Agent Damage Control

Agent-level error recovery patterns for multi-agent coordination. Maps service-level error categories to agent-level equivalents and defines escalation ladders.

## Error Categories

Agent-level error categories extend the service-level taxonomy from error-patterns:

| Agent Category | Service Equivalent | Severity | Recovery |
|----------------|-------------------|----------|----------|
| **AGENT_CRASH** | PERMANENT | Critical | Replace agent, reassign tasks |
| **CONTEXT_OVERFLOW** | RESOURCE | Error | Graceful handoff, context shed |
| **MERGE_CONFLICT** | TRANSIENT | Warning | Stop, resolve, resume |
| **PARTIAL_FAILURE** | Mixed | Varies | Triage by sub-category |

## Escalation Ladder

Three-tier escalation with clear handoff points:

```
Tier 1: Agent Self-Recovery
  Agent detects issue, attempts automated recovery
  (retry, context shed, conflict resolution)
        |
        | Fails after 2 attempts
        v
Tier 2: Lead Agent Intervention
  Lead reassigns tasks, spawns replacement agents,
  coordinates resolution across team
        |
        | Cannot resolve or CRITICAL severity
        v
Tier 3: Human Escalation
  Human notified with full context, recommended actions,
  and current state summary
```

## Quick Reference

| Scenario | First Action |
|----------|--------------|
| Agent stops responding | Check heartbeat, reassign tasks |
| Response truncation | Summarize state, create continuation |
| File conflicts after parallel work | Stop agents, lead resolves |
| Some tasks fail, others succeed | Triage by error category |

## Recovery Patterns

### Agent Crash Recovery
- Detect orphaned tasks via heartbeat monitoring
- Apply "replace don't wait" doctrine: spawn new agent immediately
- Recover state from last checkpoint or committed work
- Reassign orphaned tasks to replacement agent

### Context Overflow Handling
- Detection signals: truncated responses, repeated content, loss of coherence
- Graceful handoff: summarize state, write to file, spawn continuation
- Progressive context shedding: drop least-relevant loaded modules first

### Merge Conflict Resolution
- Stop all agents working on conflicting files
- Lead agent resolves conflicts using diff analysis
- Resume agents with updated base after resolution
- Prevention: assign non-overlapping file scopes

### Partial Failure Handling
- Triage: categorize each sub-task result (success/failure/partial)
- Salvage: commit successful work first
- Retry: attempt failed tasks with fresh context
- Report: document what succeeded and what needs manual attention

## Integration

Reference specific recovery patterns from orchestrator skills:
```markdown
On agent crash: follow leyline:error-patterns/modules/agent-damage-control.md
```

## Exit Criteria

- Failed agent identified and replaced (or escalated)
- Orphaned tasks reassigned to healthy agents
- Successful work preserved and committed
- Recovery actions logged for post-mortem

modules/classification.md

---
name: classification
description: Error classification taxonomy and detection patterns
estimated_tokens: 350
---

# Error Classification

## HTTP Status Code Mapping

```python
ERROR_CLASSIFICATION = {
    # Authentication
    401: ErrorCategory.CONFIGURATION,
    403: ErrorCategory.CONFIGURATION,

    # Client errors
    400: ErrorCategory.PERMANENT,
    404: ErrorCategory.CONFIGURATION,
    422: ErrorCategory.PERMANENT,

    # Rate limits
    429: ErrorCategory.RESOURCE,

    # Server errors (transient)
    500: ErrorCategory.TRANSIENT,
    502: ErrorCategory.TRANSIENT,
    503: ErrorCategory.TRANSIENT,
    504: ErrorCategory.TRANSIENT,
}
```

## Error Detection Patterns

### By Message Content
```python
def classify_by_message(error_msg: str) -> ErrorCategory:
    error_msg = error_msg.lower()

    if any(k in error_msg for k in ["rate limit", "quota", "exceeded"]):
        return ErrorCategory.RESOURCE

    if any(k in error_msg for k in ["auth", "token", "credential", "permission"]):
        return ErrorCategory.CONFIGURATION

    if any(k in error_msg for k in ["timeout", "connection", "network"]):
        return ErrorCategory.TRANSIENT

    if any(k in error_msg for k in ["invalid", "malformed", "syntax"]):
        return ErrorCategory.PERMANENT

    return ErrorCategory.TRANSIENT  # Default: assume retryable
```

## Service-Specific Errors

### Gemini Errors
| Error | Category | Recovery |
|-------|----------|----------|
| RESOURCE_EXHAUSTED | Resource | Wait for quota reset |
| INVALID_ARGUMENT | Permanent | Fix request format |
| PERMISSION_DENIED | Config | Check API key |
| DEADLINE_EXCEEDED | Transient | Retry with backoff |

### Qwen Errors
| Error | Category | Recovery |
|-------|----------|----------|
| RateLimitReached | Resource | Wait or switch service |
| InvalidAPIKey | Config | Verify QWEN_API_KEY |
| ModelNotFound | Config | Check model name |
| ServerError | Transient | Retry |

## Error Hierarchy

```python
class LeylineError(Exception):
    """Base error for leyline infrastructure."""
    category = ErrorCategory.TRANSIENT

class AuthenticationError(LeylineError):
    """Authentication/authorization failures."""
    category = ErrorCategory.CONFIGURATION

class RateLimitError(LeylineError):
    """Rate limit or quota exceeded."""
    category = ErrorCategory.RESOURCE

class ServiceUnavailableError(LeylineError):
    """Service temporarily unavailable."""
    category = ErrorCategory.TRANSIENT

class ConfigurationError(LeylineError):
    """Missing or invalid configuration."""
    category = ErrorCategory.CONFIGURATION
```

modules/recovery-strategies.md

---
name: recovery-strategies
description: Error recovery strategies and implementation patterns
estimated_tokens: 400
---

# Recovery Strategies

## Strategy Selection

```python
def select_recovery_strategy(error: LeylineError) -> RecoveryStrategy:
    strategies = {
        ErrorCategory.TRANSIENT: RetryWithBackoff(),
        ErrorCategory.RESOURCE: WaitOrSecondary(),
        ErrorCategory.CONFIGURATION: UserActionRequired(),
        ErrorCategory.PERMANENT: ReportAndAbort(),
    }
    return strategies[error.category]
```

## Retry With Backoff

```python
class RetryWithBackoff:
    def __init__(self, max_retries=3, base_delay=1.0):
        self.max_retries = max_retries
        self.base_delay = base_delay

    def execute(self, operation, *args, **kwargs):
        for attempt in range(self.max_retries):
            try:
                return operation(*args, **kwargs)
            except LeylineError as e:
                if e.category != ErrorCategory.TRANSIENT:
                    raise
                if attempt < self.max_retries - 1:
                    delay = self.base_delay * (2 ** attempt)
                    time.sleep(delay)
        raise MaxRetriesExceededError()
```

## Wait or Secondary

class WaitOrSecondary:
    def execute(self, error: RateLimitError, secondary_service=None):
        retry_after = error.metadata.get("retry_after", 60)

        if retry_after < 30:  # Short wait
            time.sleep(retry_after)
            return "retry"

        if secondary_service:
            return ("secondary", secondary_service)

        return ("defer", retry_after)
```

## User Action Required

```python
class UserActionRequired:
    def execute(self, error: ConfigurationError) -> dict:
        actions = {
            "auth": "Run '{service} auth login' or set {ENV_VAR}",
            "model": "Check available models with '{service} --help'",
            "config": "Verify configuration in ~/.claude/leyline/",
        }

        return {
            "status": "user_action_required",
            "message": error.message,
            "suggested_action": actions.get(
                error.metadata.get("type"),
                "Check service documentation"
            )
        }
```

## Graceful Degradation

```python
def execute_with_degradation(
    primary_fn,
            secondary_fn=None,

    degraded_fn=None
):
    """Execute with graceful degradation."""
    try:
        return primary_fn()
    except LeylineError as e:
        if e.category == ErrorCategory.TRANSIENT and secondary_fn:
            return secondary_fn()
        if degraded_fn:
            return degraded_fn(partial=True)
        raise
```

## Logging and Alerting

```python
def log_error_with_context(error: LeylineError, context: dict):
    """Log error with full context for debugging."""
    log_entry = {
        "timestamp": datetime.utcnow().isoformat(),
        "error_type": type(error).__name__,
        "category": error.category.value,
        "message": 

Sponsored

Ads related to error-patterns and adjacent AI workflows.