error-patterns
Provides error classification, recovery, and graceful-degradation patterns. Use when implementing error handling or debugging resilience failures in…
它会碰到什么
这一栏是扫描器报的事实,不是结论。命中多不等于有毒(安全工具、规则库、示例脚本本来就会包含危险写法),命中少也不等于干净。它和你手上的凭据、文件、网络有什么关系,需要你自己看。
技能内容
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
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.mdfor error taxonomy - Recovery: See
modules/recovery-strategies.mdfor handling patterns - Agent Damage Control: See
modules/agent-damage-control.mdfor multi-agent error recovery and escalation
Exit Criteria
- Error classified correctly
- Appropriate recovery attempted
- User-actionable message provided
- Error logged for debugging
想直接用这个技能?
本站把开放许可(MIT / Apache 等)的技能按仓库打包整理到网盘,点一下转存到你自己的网盘,不用一个个从 GitHub 拉。许可未声明的技能只给原始仓库链接,不打包。
它属于哪个仓库
plugins/leyline/skills/error-patterns/SKILL.md同一个仓库里的其他技能
- claude-code-plugin-reference
- night-market-architecture-contract
- night-market-build-and-env
- night-market-change-control
- night-market-collective-memory
- night-market-completion-integrity-campaign
- night-market-config-catalog
- night-market-debugging-playbook
- night-market-diagnostics-toolkit
- night-market-docs-and-writing
- night-market-failure-archaeology
- night-market-model-and-harness-updates