Communityコーディング&開発github.com

mianhtsys/landingMod3

例外処理、Result型、エラー伝播、グレースフルデグラデーションなど、複数言語にわたるエラーハンドリングパターンを習得し、堅牢なアプリケーションを構築します。エラー処理の実装、API設計、アプリケーション信頼性の向上に使用します。

landingMod3 とは?

このスキルは、例外処理、Result型、エラー伝播、グレースフルデグラデーションなど、複数言語にわたるエラーハンドリングパターンを習得し、堅牢なアプリケーションを構築するための包括的なガイドを提供します。新しい機能へのエラー処理の実装、エラーに強いAPIの設計、本番環境の問題のデバッグ、アプリケーションの信頼性向上に役立ちます。主なトピックとして、例外対Result型の使い分け、回復可能/回復不能エラーの分類、リトライやサーキットブレーカーパターンの実装、非同期/並行処理でのエラー対処法、フォールトトレラントな分散システムの構築が含まれます。ベストプラクティスとして、早期失敗(Fail Fast)、コンテキストの保存、意味のあるメッセージ、適切なログ出力、リソースのクリーンアップ、エラーの黙殺防止、型安全なエラー使用などが推奨されています。Pythonによる具体的なエラー処理コード例も提供されており、実際の開発現場で即座に活用できる知識を身につけることができます。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/mianhtsys/landingMod3/tree/HEAD/MODULO_3_DESARROLLO_AL_LADO_DEL_CLIENTE_Y_SERVIDOR_WEB/architecture-skills-framework/.agents/skills/error-handling-patterns

Installed? Explore more コーディング&開発 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

エラーハンドリングパターン

堅牢なエラーハンドリング戦略を用いて、障害を優雅に処理し、優れたデバッグ体験を提供する耐障害性の高いアプリケーションを構築します。

このスキルを使うタイミング

  • 新機能へのエラー処理の実装
  • エラーに強いAPIの設計
  • 本番環境の問題のデバッグ
  • アプリケーションの信頼性向上
  • ユーザーと開発者向けのより良いエラーメッセージの作成
  • リトライとサーキットブレーカーパターンの実装
  • 非同期/並行処理エラーの処理
  • フォールトトレラントな分散システムの構築

コアコンセプト

1. エラーハンドリングの哲学

例外 vs Result型:

  • 例外: 従来のtry-catch、制御フローを中断する
  • Result型: 明示的な成功/失敗、関数型アプローチ
  • エラーコード: Cスタイル、規律が必要
  • Option/Maybe型: null許容値向け

それぞれを使うタイミング:

  • 例外: 予期せぬエラー、例外的な状況
  • Result型: 予期されるエラー、バリデーション失敗
  • Panic/クラッシュ: 回復不能なエラー、プログラミングバグ

2. エラーカテゴリ

回復可能なエラー:

  • ネットワークタイムアウト
  • ファイルが見つからない
  • 無効なユーザー入力
  • APIレート制限

回復不能なエラー:

  • メモリ不足
  • スタックオーバーフロー
  • プログラミングバグ(nullポインタなど)

詳細パターンと実例

詳細なパターン文書は references/details.md にあります。上記のナビゲーションティアでは不十分な場合は、そのファイルを読んでください。

ベストプラクティス

  1. 早期に失敗する: 入力を早期に検証し、迅速に失敗する
  2. コンテキストを保持する: スタックトレース、メタデータ、タイムスタンプを含める
  3. 意味のあるメッセージ: 何が起こったのか、どう修正するのかを説明する
  4. 適切にログ出力する: エラー=ログ出力、予期される失敗=ログを大量に出力しない
  5. 適切なレベルで処理する: 意味のある処理ができる場所でキャッチする
  6. リソースをクリーンアップする: try-finally、コンテキストマネージャ、deferを使用する
  7. エラーを飲み込まない: ログ出力または再スローし、静かに無視しない
  8. 型安全なエラー: 可能な限り型付きエラーを使用する
# 良いエラー処理の例
def process_order(order_id: str) -> Order:
    """包括的なエラー処理で注文を処理する"""
    try:
        # 入力の検証
        if not order_id:
            raise ValidationError("注文IDは必須です")

        # 注文の取得
        order = db.get_order(order_id)
        if not order:
            raise NotFoundError("注文", order_id)

        # 支払いの処理
        try:
            payment_result = payment_service.charge(order.total)
        except PaymentServiceError as e:
            # 外部サービスのエラーをログ出力してラップする
            logger.error(f"注文 {order_id} の支払い失敗: {e}")
            raise ExternalServiceError(
                f"支払い処理に失敗しました",
                service="payment_service",
                details={"order_id": order_id, "amount": order.total}
            ) from e

        # 注文の更新
        order.status = "completed"
        order.payment_id = payment_result.id
        db.save(order)

        return order

    except ApplicationError:
        # 既知のアプリケーションエラーは再スロー
        raise
    except Exception as e:
        # 予期しないエラーをログ出力
        logger.exception(f"注文 {order_id} の処理中に予期しないエラーが発生しました")
        raise ApplicationError(
            "注文処理に失敗しました",
            code="INTERNAL_ERROR"
        ) from e

よくある落とし穴

  • 広すぎるキャッチ: except Exception はバグを隠す
  • 空のキャッチブロック: エラーを黙殺する
  • ログ出力と再スロー: 重複したログエントリを作成する
  • クリーンアップの欠如: ファイルやコネクションを閉じるのを忘れる
  • 貧弱なエラーメッセージ: 「エラーが発生しました」は役に立たない
  • エラーコードの返却: 例外またはResult型を使用する
  • 非同期エラーの無視: 未処理のPromise拒否

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

mianhtsys/landingMod3

Implement WCAG 2.2 compliant interfaces with mobile accessibility, inclusive design patterns, and assistive technology support. Use when auditing accessibility, implementing ARIA patterns, building for screen readers, or ensuring inclusive user experiences.

mianhtsys/landingMod3

Master REST and GraphQL API design principles to build intuitive, scalable, and maintainable APIs that delight developers. Use when designing new APIs, reviewing API specifications, or establishing API design standards.

mianhtsys/landingMod3

Diseña y compara alternativas arquitectónicas trazables a RF/RNF sin implementar código.

mianhtsys/landingMod3

Implement proven backend architecture patterns including Clean Architecture, Hexagonal Architecture, and Domain-Driven Design. Use this skill when designing clean architecture for a new microservice, when refactoring a monolith to use bounded contexts, when implementing hexagonal or onion architecture patterns, or when debugging dependency cycles between application layers.

mianhtsys/landingMod3

Revisión adversarial de la arquitectura contra RF/RNF, detectando contradicciones, cobertura faltante y complejidad innecesaria.

mianhtsys/landingMod3

Master authentication and authorization patterns including JWT, OAuth2, session management, and RBAC to build secure, scalable access control systems. Use when implementing auth systems, securing APIs, or debugging security issues.

mianhtsys/landingMod3

>- Generate grounded-and-verified, engine-agnostic database documentation that reaches 100% parity with the real schema. Introspects the LIVE database as ground truth and cross-validates it against ORM models, migrations, generated types, seeds, and application queries, then proves completeness by diffing the docs back against the database. Produces ER diagrams (mermaid), per-table data dictionaries, and a machine-readable schema.json. Works with PostgreSQL, MySQL, SQL Server, and SQLite across any ORM (Prisma, TypeORM, Drizzle, Sequelize, Knex, Django, Rails) or raw SQL. Use when asked to document a database, produce an ERD or data dictionary, write db/schema docs, audit schema drift, or refresh existing DB docs.

mianhtsys/landingMod3

Compara estrategias de persistencia y motores de datos según consistencia, concurrencia, volumen, recuperación y operación.

mianhtsys/landingMod3

Design robust, scalable database schemas for SQL and NoSQL databases. Provides normalization guidelines, indexing strategies, migration patterns, constraint design, and performance optimization. Ensures data integrity, query performance, and maintainable data models.

mianhtsys/landingMod3

Consolida análisis especializados en una recomendación arquitectónica, matriz de decisión, ADR y plan de validación.

mianhtsys/landingMod3

Build and maintain web frontends — component architecture, state management, API integration, responsive layout, client-side performance, and frontend testing patterns. Framework agnostic, focused on web frontend implementation. Do not use for backend service implementation, data engineering, or platform infrastructure work.

mianhtsys/landingMod3

Evalúa despliegue, contenedores, escalado, alta disponibilidad, observabilidad, backup, recuperación y CI/CD de forma proporcional.

mianhtsys/landingMod3

Execute read-only SQL queries against multiple Microsoft SQL Server databases. Use when: (1) querying MSSQL/SQL Server databases, (2) exploring database schemas/tables, (3) running SELECT queries for data analysis, (4) checking database contents. Supports multiple database connections with descriptions for intelligent auto-selection. Blocks all write operations (INSERT, UPDATE, DELETE, DROP, etc.) for safety.

mianhtsys/landingMod3

Generate and maintain OpenAPI 3.1 specifications from code, design-first specs, and validation patterns. Use when creating API documentation, generating SDKs, or ensuring API contract compliance.

mianhtsys/landingMod3

PHP 8.0+ development — XAMPP, RESTful APIs, PDO/MySQL/MariaDB, and authentication. Use when building PHP backends, creating API endpoints, configuring XAMPP, or integrating PHP with databases.

mianhtsys/landingMod3

Use this skill when designing or reviewing a PostgreSQL-specific schema. Covers best-practices, data types, indexing, constraints, performance patterns, and advanced features

mianhtsys/landingMod3

Analiza requisitos funcionales y no funcionales, reglas, restricciones, capacidad y ambigüedades antes de seleccionar tecnologías.

mianhtsys/landingMod3

Implement modern responsive layouts using container queries, fluid typography, CSS Grid, and mobile-first breakpoint strategies. Use when building adaptive interfaces, implementing fluid layouts, or creating component-level responsive behavior.

mianhtsys/landingMod3

>- Use when designing or implementing software securely: define security requirements, threat-model a feature, choose secure defaults, design authentication and authorization, handle untrusted data and secrets, evaluate dependencies, design multi-tenant trust boundaries, or review security-sensitive changes. Use for prevention during requirements, design, implementation, and review; not for post-build security assessments or scanning an existing codebase.

mianhtsys/landingMod3

Revisa seguridad arquitectónica, identidad, autorización, secretos, APIs, auditoría, fraude y resiliencia antes de implementar.

関連スキル