[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M73B7JXNSWBHW2RSMDX4QWR6":3,"skill-same:01M73B7JXNSWBHW2RSMDX4QWR6":67},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":43,"commitSha":44,"skillDirectory":45,"forksCount":46,"repositoryHtmlUrl":47,"repositoryHomepageUrl":48,"ownerHtmlUrl":49,"ownerBlogUrl":50,"ownerDescription":51,"updatedAt":52,"install":53,"resources":66},"01M73B7JXNSWBHW2RSMDX4QWR6","error-handling-patterns",null,"Production error handling — typed errors, Result type, error boundaries, structured logging, retry strategies","Horonomos-laps\u002FYana-AI","Horonomos-laps","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F355299122?v=4","01M76B3QPXE88ET2SQPDPVATZT"," Horonomos-laps","01M72ZQRJPCYPSSWT4D00VJR2A",13,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Ferror-handling-patterns\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: error-handling-patterns\ndescription: Production error handling — typed errors, Result type, error boundaries, structured logging, retry strategies\ntriggers:\n  - error handling\n  - exception handling\n  - error boundary\n  - result type\n  - typed errors\n  - error handling python\n  - error handling typescript\n  - retry strategy\n  - error logging best practice\n  - production error handling\ndo_not_use_for:\n  - validation only — use pydantic for input validation\n  - observability\u002Ftracing — use langfuse\n  - AI-specific anti-patterns — use ai-code-maintainability\nsee_also:\n  - ai-code-maintainability\n  - type-safety-patterns\n  - testing-strategy\n---\n\n# Error Handling Patterns\n\n## Python: Typed Exception Hierarchy\n\n```python\n# Define domain-specific exception tree\nclass AppError(Exception):\n    \"\"\"Base for all application errors.\"\"\"\n    def __init__(self, message: str, code: str, **context):\n        super().__init__(message)\n        self.code = code\n        self.context = context\n\nclass NotFoundError(AppError):\n    def __init__(self, resource: str, resource_id: str):\n        super().__init__(f\"{resource} {resource_id} not found\",\n                         code=\"NOT_FOUND\",\n                         resource=resource, resource_id=resource_id)\n\nclass ValidationError(AppError):\n    def __init__(self, field: str, reason: str):\n        super().__init__(f\"Validation failed: {field} — {reason}\",\n                         code=\"VALIDATION_ERROR\",\n                         field=field, reason=reason)\n\nclass ExternalServiceError(AppError):\n    def __init__(self, service: str, status: int, detail: str):\n        super().__init__(f\"{service} returned {status}: {detail}\",\n                         code=\"EXTERNAL_ERROR\",\n                         service=service, status=status)\n```\n\n## Python: Result Type (no exceptions for control flow)\n\n```python\nfrom typing import Generic, TypeVar, Union\nfrom dataclasses import dataclass\n\nT = TypeVar(\"T\")\nE = TypeVar(\"E\")\n\n@dataclass(frozen=True)\nclass Ok(Generic[T]):\n    value: T\n    ok: bool = True\n\n@dataclass(frozen=True)\nclass Err(Generic[E]):\n    error: E\n    ok: bool = False\n\nResult = Union[Ok[T], Err[E]]\n\n# Usage\ndef parse_age(raw: str) -> Result[int, str]:\n    try:\n        age = int(raw)\n        if not 0 \u003C= age \u003C= 150:\n            return Err(f\"age {age} out of range [0, 150]\")\n        return Ok(age)\n    except ValueError:\n        return Err(f\"'{raw}' is not a valid integer\")\n\nresult = parse_age(\"25\")\nmatch result:\n    case Ok(value=age):\n        print(f\"Valid age: {age}\")\n    case Err(error=msg):\n        print(f\"Error: {msg}\")\n```\n\n## TypeScript: Result Type\n\n```typescript\ntype Ok\u003CT> = { ok: true; value: T };\ntype Err\u003CE> = { ok: false; error: E };\ntype Result\u003CT, E = string> = Ok\u003CT> | Err\u003CE>;\n\nconst ok = \u003CT>(value: T): Ok\u003CT> => ({ ok: true, value });\nconst err = \u003CE>(error: E): Err\u003CE> => ({ ok: false, error });\n\nasync function fetchUser(id: string): Promise\u003CResult\u003CUser>> {\n  try {\n    const user = await db.findUser(id);\n    if (!user) return err(`User ${id} not found`);\n    return ok(user);\n  } catch (e) {\n    logger.error(\"fetchUser failed\", { id, error: e });\n    return err(\"database error\");\n  }\n}\n\n\u002F\u002F Exhaustive handling — TypeScript checks you handled both cases\nconst result = await fetchUser(id);\nif (!result.ok) {\n  res.status(404).json({ error: result.error });\n  return;\n}\nconst user = result.value; \u002F\u002F User — not undefined\n```\n\n## Structured Error Logging\n\n```python\nimport structlog\nfrom typing import Any\n\nlog = structlog.get_logger()\n\ndef process_payment(order_id: str, amount: float) -> None:\n    log_ctx = log.bind(order_id=order_id, amount=amount, action=\"payment\")\n    try:\n        log_ctx.info(\"payment_started\")\n        result = stripe.charge(order_id, amount)\n        log_ctx.info(\"payment_succeeded\", charge_id=result.id)\n    except stripe.CardError as e:\n        log_ctx.warning(\"payment_declined\", code=e.code, message=e.user_message)\n        raise\n    except stripe.StripeError as e:\n        log_ctx.error(\"payment_stripe_error\", error_type=type(e).__name__, detail=str(e))\n        raise ExternalServiceError(\"stripe\", 500, str(e)) from e\n    except Exception as e:\n        log_ctx.exception(\"payment_unexpected_error\")  # includes stack trace\n        raise\n```\n\n## Retry with Tenacity\n\n```python\nfrom tenacity import (\n    retry, stop_after_attempt, wait_exponential,\n    retry_if_exception_type, before_sleep_log,\n    RetryError,\n)\nimport logging\n\n@retry(\n    retry=retry_if_exception_type((TimeoutError, ConnectionError)),\n    stop=stop_after_attempt(3),\n    wait=wait_exponential(multiplier=1, min=1, max=30),\n    before_sleep=before_sleep_log(logging.getLogger(__name__), logging.WARNING),\n    reraise=True,\n)\nasync def call_external_api(url: str) -> dict:\n    async with httpx.AsyncClient() as client:\n        response = await client.get(url, timeout=10.0)\n        response.raise_for_status()\n        return response.json()\n\ntry:\n    data = await call_external_api(\"https:\u002F\u002Fapi.example.com\u002Fdata\")\nexcept RetryError as e:\n    # All retries exhausted\n    raise ExternalServiceError(\"example-api\", 503, \"all retries failed\") from e\n```\n\n## Error Boundaries (React)\n\n```typescript\nimport React, { Component, ErrorInfo, ReactNode } from 'react';\n\ninterface ErrorBoundaryState {\n  hasError: boolean;\n  error: Error | null;\n}\n\nclass ErrorBoundary extends Component\u003C\n  { children: ReactNode; fallback: ReactNode },\n  ErrorBoundaryState\n> {\n  state: ErrorBoundaryState = { hasError: false, error: null };\n\n  static getDerivedStateFromError(error: Error): ErrorBoundaryState {\n    return { hasError: true, error };\n  }\n\n  componentDidCatch(error: Error, info: ErrorInfo): void {\n    logger.error('React error boundary caught', {\n      error: error.message,\n      component: info.componentStack,\n    });\n  }\n\n  render(): ReactNode {\n    if (this.state.hasError) return this.props.fallback;\n    return this.props.children;\n  }\n}\n\n\u002F\u002F Usage\n\u003CErrorBoundary fallback={\u003CErrorPage message=\"Something went wrong\" \u002F>}>\n  \u003CRiskyComponent \u002F>\n\u003C\u002FErrorBoundary>\n```\n\n## Anti-Fake-Pass Checks\n\n- `log.exception()` includes stack trace — use for unexpected errors, not expected ones\n- `reraise=True` in tenacity means after all retries fail, original exception propagates\n- Result type only works if callers check `result.ok` — TypeScript enforces this, Python does not\n- `before_sleep_log` requires a Python `logging.Logger`, not structlog logger — use `logging.getLogger()`\n- Error boundaries only catch rendering errors — async errors (useEffect, event handlers) need try\u002Fcatch\n- Match statement (Python 3.10+) — use `if\u002Felif` for 3.9 compat\n","# Error Handling Patterns\n\n## Python: Typed Exception Hierarchy\n\n```python\n# Define domain-specific exception tree\nclass AppError(Exception):\n    \"\"\"Base for all application errors.\"\"\"\n    def __init__(self, message: str, code: str, **context):\n        super().__init__(message)\n        self.code = code\n        self.context = context\n\nclass NotFoundError(AppError):\n    def __init__(self, resource: str, resource_id: str):\n        super().__init__(f\"{resource} {resource_id} not found\",\n                         code=\"NOT_FOUND\",\n                         resource=resource, resource_id=resource_id)\n\nclass ValidationError(AppError):\n    def __init__(self, field: str, reason: str):\n        super().__init__(f\"Validation failed: {field} — {reason}\",\n                         code=\"VALIDATION_ERROR\",\n                         field=field, reason=reason)\n\nclass ExternalServiceError(AppError):\n    def __init__(self, service: str, status: int, detail: str):\n        super().__init__(f\"{service} returned {status}: {detail}\",\n                         code=\"EXTERNAL_ERROR\",\n                         service=service, status=status)\n```\n\n## Python: Result Type (no exceptions for control flow)\n\n```python\nfrom typing import Generic, TypeVar, Union\nfrom dataclasses import dataclass\n\nT = TypeVar(\"T\")\nE = TypeVar(\"E\")\n\n@dataclass(frozen=True)\nclass Ok(Generic[T]):\n    value: T\n    ok: bool = True\n\n@dataclass(frozen=True)\nclass Err(Generic[E]):\n    error: E\n    ok: bool = False\n\nResult = Union[Ok[T], Err[E]]\n\n# Usage\ndef parse_age(raw: str) -> Result[int, str]:\n    try:\n        age = int(raw)\n        if not 0 \u003C= age \u003C= 150:\n            return Err(f\"age {age} out of range [0, 150]\")\n        return Ok(age)\n    except ValueError:\n        return Err(f\"'{raw}' is not a valid integer\")\n\nresult = parse_age(\"25\")\nmatch result:\n    case Ok(value=age):\n        print(f\"Valid age: {age}\")\n    case Err(error=msg):\n        print(f\"Error: {msg}\")\n```\n\n## TypeScript: Result Type\n\n```typescript\ntype Ok\u003CT> = { ok: true; value: T };\ntype Err\u003CE> = { ok: false; error: E };\ntype Result\u003CT, E = string> = Ok\u003CT> | Err\u003CE>;\n\nconst ok = \u003CT>(value: T): Ok\u003CT> => ({ ok: true, value });\nconst err = \u003CE>(error: E): Err\u003CE> => ({ ok: false, error });\n\nasync function fetchUser(id: string): Promise\u003CResult\u003CUser>> {\n  try {\n    const user = await db.findUser(id);\n    if (!user) return err(`User ${id} not found`);\n    return ok(user);\n  } catch (e) {\n    logger.error(\"fetchUser failed\", { id, error: e });\n    return err(\"database error\");\n  }\n}\n\n\u002F\u002F Exhaustive handling — TypeScript checks you handled both cases\nconst result = await fetchUser(id);\nif (!result.ok) {\n  res.status(404).json({ error: result.error });\n  return;\n}\nconst user = result.value; \u002F\u002F User — not undefined\n```\n\n## Structured Error Logging\n\n```python\nimport structlog\nfrom typing import Any\n\nlog = structlog.get_logger()\n\ndef process_payment(order_id: str, amount: float) -> None:\n    log_ctx = log.bind(order_id=order_id, amount=amount, action=\"payment\")\n    try:\n        log_ctx.info(\"payment_started\")\n        result = stripe.charge(order_id, amount)\n        log_ctx.info(\"payment_succeeded\", charge_id=result.id)\n    except stripe.CardError as e:\n        log_ctx.warning(\"payment_declined\", code=e.code, message=e.user_message)\n        raise\n    except stripe.StripeError as e:\n        log_ctx.error(\"payment_stripe_error\", error_type=type(e).__name__, detail=str(e))\n        raise ExternalServiceError(\"stripe\", 500, str(e)) from e\n    except Exception as e:\n        log_ctx.exception(\"payment_unexpected_error\")  # includes stack trace\n        raise\n```\n\n## Retry with Tenacity\n\n```python\nfrom tenacity import (\n    retry, stop_after_attempt, wait_exponential,\n    retry_if_exception_type, before_sleep_log,\n    RetryError,\n)\nimport logging\n\n@retry(\n    retry=retry_if_exception_type((TimeoutError, ConnectionError)),\n    stop=stop_after_attempt(3),\n    wait=wait_exponential(multiplier=1, min=1, max=30),\n    before_sleep=before_sleep_log(logging.getLogger(__name__), logging.WARNING),\n    reraise=True,\n)\nasync def call_external_api(url: str) -> dict:\n    async with httpx.AsyncClient() as client:\n        response = await client.get(url, timeout=10.0)\n        response.raise_for_status()\n        return response.json()\n\ntry:\n    data = await call_external_api(\"https:\u002F\u002Fapi.example.com\u002Fdata\")\nexcept RetryError as e:\n    # All retries exhausted\n    raise ExternalServiceError(\"example-api\", 503, \"all retries failed\") from e\n```\n\n## Error Boundaries (React)\n\n```typescript\nimport React, { Component, ErrorInfo, ReactNode } from 'react';\n\ninterface ErrorBoundaryState {\n  hasError: boolean;\n  error: Error | null;\n}\n\nclass ErrorBoundary extends Component\u003C\n  { children: ReactNode; fallback: ReactNode },\n  ErrorBoundaryState\n> {\n  state: ErrorBoundaryState = { hasError: false, error: null };\n\n  static getDerivedStateFromError(error: Error): ErrorBoundaryState {\n    return { hasError: true, error };\n  }\n\n  componentDidCatch(error: Error, info: ErrorInfo): void {\n    logger.error('React error boundary caught', {\n      error: error.message,\n      component: info.componentStack,\n    });\n  }\n\n  render(): ReactNode {\n    if (this.state.hasError) return this.props.fallback;\n    return this.props.children;\n  }\n}\n\n\u002F\u002F Usage\n\u003CErrorBoundary fallback={\u003CErrorPage message=\"Something went wrong\" \u002F>}>\n  \u003CRiskyComponent \u002F>\n\u003C\u002FErrorBoundary>\n```\n\n## Anti-Fake-Pass Checks\n\n- `log.exception()` includes stack trace — use for unexpected errors, not expected ones\n- `reraise=True` in tenacity means after all retries fail, original exception propagates\n- Result type only works if callers check `result.ok` — TypeScript enforces this, Python does not\n- `before_sleep_log` requires a Python `logging.Logger`, not structlog logger — use `logging.getLogger()`\n- Error boundaries only catch rendering errors — async errors (useEffect, event handlers) need try\u002Fcatch\n- Match statement (Python 3.10+) — use `if\u002Felif` for 3.9 compat\n",{"name":5,"see_also":24,"triggers":28,"description":7,"do_not_use_for":39},[25,26,27],"ai-code-maintainability","type-safety-patterns","testing-strategy",[29,30,31,32,33,34,35,36,37,38],"error handling","exception handling","error boundary","result type","typed errors","error handling python","error handling typescript","retry strategy","error logging best practice","production error handling",[40,41,42],"validation only — use pydantic for input validation","observability\u002Ftracing — use langfuse","AI-specific anti-patterns — use ai-code-maintainability","main","481dcd7dd2e288b9d627a2bd017db70e64e6c6fa","core\u002Fskills\u002Ferror-handling-patterns",2,"https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI","https:\u002F\u002Fyana.vutam.link\u002F","https:\u002F\u002Fgithub.com\u002FHoronomos-laps","https:\u002F\u002Fyana.vutam.link","An open-source governed runtime & execution environment for multi-agent AI systems.","2026-11-14 13:24:09",{"source":8,"skillName":5,"commands":54,"prompt":64,"zipAvailable":65},[55,58,61],{"tool":56,"command":57},"npx","npx skills add Horonomos-laps\u002FYana-AI --skill error-handling-patterns",{"tool":59,"command":60},"bunx","bunx skills add Horonomos-laps\u002FYana-AI --skill error-handling-patterns",{"tool":62,"command":63},"pnpm","pnpm dlx skills add Horonomos-laps\u002FYana-AI --skill error-handling-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Ferror-handling-patterns\u002FSKILL.md",true,[],[68,76,83,91,99,107],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":72,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M735GKET5YVYKAY62W2P5YXB","openai--sentry--sentry","Use when the user asks to inspect Sentry issues or events, summarize recent production errors, or pull basic Sentry health data via the Sentry API; perform read-only queries with the bundled script and require `SENTRY_AUTH_TOKEN`.","MIT","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fopenai--sentry--sentry\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M73DCAP83T17HY7SMGK7MGFE","ito-basket-compare","Compare Itô prediction-market baskets against a user's knowledge base, portfolio notes, financial context, watchlist, or research thesis. Use for read-only basket comparison and gap analysis without investment advice or live trading.","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fito-basket-compare\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":87,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M734CYEMZFDR3KH6SW0JP8TD","implementing-network-traffic-baselining","Build network traffic baselines from NetFlow\u002FIPFIX data using Python pandas for statistical analysis, z-score anomaly detection, and hourly\u002Fdaily traffic pattern profiling","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-network-traffic-baselining\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-network-traffic-baselining\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":95,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":19},"01M73ASZ6NJRJM44Z2P84NGQ3Q","detecting-evasion-techniques-in-endpoint-logs","Detects defense evasion techniques used by adversaries in endpoint logs including log tampering, timestomping, process injection, and security tool disabling. Use when investigating suspicious endpoint behavior, building detection rules for evasion tactics, or conducting threat hunting for stealthy adversary activity. Activates for requests involving evasion detection, defense evasion analysis, log tampering detection, or MITRE ATT&CK TA0005.","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fdetecting-evasion-techniques-in-endpoint-logs\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fdetecting-evasion-techniques-in-endpoint-logs\u002FSKILL.md",[],[],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":103,"sourceHtmlUrl":104,"categories":105,"keywords":106,"publishedAt":19},"01M734AFNXD06Z78QRK0VKGT7Q","implementing-microsegmentation-with-guardicore","Implementing microsegmentation using Akamai Guardicore Segmentation to map application dependencies, create granular network policies, visualize east-west traffic flows, and enforce least-privilege communication between workloads across data centers and cloud.","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-microsegmentation-with-guardicore\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-microsegmentation-with-guardicore\u002FSKILL.md",[],[],{"skillNo":108,"name":109,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":110,"categories":111,"keywords":112,"publishedAt":19},"01M736TK27QMCXK0DVCH25SJN5","ramdisk-tmpfs-patterns","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Framdisk-tmpfs-patterns\u002FSKILL.md",[],[]]