跳到正文
cccskills
免费在 GitHub 公开

add-error-handling

Implement comprehensive error handling for Python code paths to keep services resilient and user-friendly. Use when failures are currently silent or exceptions leak through.

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(1)

  • SKILL.md2.2 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Add Error Handling

Strengthen resilience by catching and recovering from predictable failures.

Steps

  1. Error detection

    • Identify failure points (network calls, file I/O, external APIs)
    • Find unhandled exceptions, missing validations, and async errors
    • Ensure coroutine boundaries (async def) wrap awaited calls with exception handling
  2. Handling strategy

    • Use specific exception types (ValueError, RuntimeError, custom errors) instead of bare except
    • Raise from lower-level exceptions (raise MyError(...) from exc) to preserve context
    • Validate inputs early (pydantic models, schema checks, assert statements for invariants)
    • Log structured errors with correlation IDs or context-specific metadata
  3. Recovery mechanisms

    • Retry transient failures with exponential backoff (tenacity, async_retry)
    • Provide fallbacks (cached data, defaults) when external services fail
    • Use context managers (with statements) to guarantee cleanup
    • Propagate user-friendly errors to callers while logging detailed internals
  4. User experience

    • Return clear API responses (HTTP 4xx/5xx) with actionable messages
    • Add loading states or retries for UI/integration components when backend requests fail
    • Suggest remediation steps in logs/docs if manual intervention is required

Checklist

  • Identified every potential failure point in the changed code
  • Added validation and sanitization for external inputs
  • Logged meaningful error details without leaking secrets
  • Wrapped async calls with appropriate try/except or asyncio.wait_for
  • Added retries or fallbacks for transient dependencies
  • Raised custom exceptions with from chains for traceability
  • Provided clear user-facing messages or HTTP status codes

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Tabular and numerical data analysis with descriptive statistics and insights. Use when the user provides data, tables, CSVs, or numbers and wants analysis.

中文简介正在准备中。当前显示原文说明。

Unique-AG/ai52026年10月19日 更新

Financial factsheet analysis with key metrics extraction and investment rationale

中文简介正在准备中。当前显示原文说明。

Unique-AG/ai52026年10月19日 更新

ci-fix

免费

Diagnose and fix CI failures without leaving your editor.

中文简介正在准备中。当前显示原文说明。

Unique-AG/ai52026年10月19日 更新

Reproduce ai-repo PR checks locally with Poe and CI scripts, including per-package typecheck and coverage behavior. Use when validating changes before push or when user asks which local commands match CI.

中文简介正在准备中。当前显示原文说明。

Unique-AG/ai52026年10月19日 更新

Ask clarifying questions before implementing to ensure Python requirements are understood. Use when a task lacks detail, dependencies are unclear, or multiple interpretations are possible.

中文简介正在准备中。当前显示原文说明。

Unique-AG/ai52026年10月19日 更新

Delete local git branches whose remotes are gone, after verifying via gh CLI that each was actually merged.

中文简介正在准备中。当前显示原文说明。

Unique-AG/ai52026年10月19日 更新

查看 Unique-AG 的全部技能

报告此技能的问题