jpskill.com
📦 その他 コミュニティ

error-handling-gate

エラー発生時に、ユーザーが理解しやすい情報を提供し、丁寧な対応ができているかを確認することで、問題点を警告として知らせ、より使いやすいシステムへと改善するSkill。

📜 元の英語説明(参考)

Verify errors are handled gracefully with meaningful user feedback. Issues result in WARNINGS.

🇯🇵 日本人クリエイター向け解説

一言でいうと

エラー発生時に、ユーザーが理解しやすい情報を提供し、丁寧な対応ができているかを確認することで、問題点を警告として知らせ、より使いやすいシステムへと改善するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o error-handling-gate.zip https://jpskill.com/download/18282.zip && unzip -o error-handling-gate.zip && rm error-handling-gate.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/18282.zip -OutFile "$d\error-handling-gate.zip"; Expand-Archive "$d\error-handling-gate.zip" -DestinationPath $d -Force; ri "$d\error-handling-gate.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して error-handling-gate.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → error-handling-gate フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

Gate 3: エラーハンドリングレビュー

「ハッピーパスのコードは簡単です。エラーハンドリングこそが、シニアエンジニアが輝く場所です。」

目的

このゲートは、コードがエラーを適切に処理し、ユーザーに意味のあるフィードバックを提供し、エラーを黙って握りつぶさないことを保証します。

ゲートステータス

  • PASS — エラーハンドリングは適切です
  • WARNING — 対処すべき問題が見つかりました

ゲートの質問

質問 1: 失敗シナリオ

「[main operation] が失敗した場合、何が起こりますか?ユーザーエクスペリエンスについて説明してください。」

注目点:

  • 失敗モードの認識
  • ユーザーフレンドリーなエラーメッセージ
  • 回復オプション(リトライ、フォールバック)
  • サイレントな失敗がないこと

シナリオ例:

  • ネットワークリクエストが失敗する
  • データベースがダウンしている
  • バリデーションが失敗する
  • サードパーティの API エラー

質問 2: ユーザーフィードバック

「エラーが発生した場合、ユーザーには何が表示されますか?次に何をすべきかを理解できますか?」

注目点:

  • 役立つ、専門用語を使わないメッセージ
  • 実行可能なガイダンス(「もう一度試してください」、「接続を確認してください」)
  • UI 内の適切なエラー配置

質問 3: エラーの可視性

「何か問題が発生した場合、本番環境でこれをどのようにデバッグしますか?」

注目点:

  • エラーがログに記録される
  • ログに十分なコンテキストがある
  • ログに機密データが含まれていない
  • エラートラッキングの認識 (Sentry など)

エラーハンドリングチェックリスト

非同期処理

  • [ ] すべての非同期呼び出しが try/catch または .catch() でラップされている
  • [ ] 空の catch ブロックがない
  • [ ] エラーにコンテキストが含まれている(どの操作か、どのデータか)
  • [ ] クリーンアップのための finally ブロック (ローディング状態など)

ユーザーエクスペリエンス

  • [ ] ユーザーフレンドリーなエラーメッセージ(専門用語を使用しない)
  • [ ] エラーが実行可能である(ユーザーは何ができるか?)
  • [ ] エラー時にローディング状態がクリアされる
  • [ ] 適切な場合にリトライオプションがある

ロギングとデバッグ

  • [ ] エラーがコンテキストとともにログに記録される
  • [ ] エラーログに機密データが含まれていない
  • [ ] 分類のためのエラータイプ/コード
  • [ ] 開発環境でスタックトレースが利用可能

エッジケース

  • [ ] 空の状態が処理される
  • [ ] タイムアウト処理
  • [ ] 部分的な失敗の処理(一部のアイテムは成功し、一部は失敗する)
  • [ ] 同時リクエストの処理

レスポンステンプレート

PASS の場合

✅ ERROR HANDLING GATE: PASSED

エラーハンドリングは堅牢に見えます:
- 非同期処理は適切にラップされています
- ユーザーフレンドリーなエラーメッセージ
- デバッグのためにエラーがログに記録されています

次のゲートに進みます...

WARNING の場合

⚠️ ERROR HANDLING GATE: WARNING

[X] 件のエラーハンドリングに関する懸念事項が見つかりました:

**Issue 1: [空の catch ブロック / エラーハンドリングの欠落]**
場所: `file.ts:42`
質問: 「これがサイレントに失敗した場合、何が起こりますか?」

**Issue 2: [技術的なエラーがユーザーに表示される]**
場所: `file.ts:88`
質問: 「ユーザーは 'TypeError: Cannot read property...' を理解できますか?」

**Issue 3: [ローディング状態のクリーンアップがない]**
場所: `file.ts:100`
質問: 「これが失敗した場合、ローディングスピナーはどうなりますか?」

良好なユーザーエクスペリエンスを確保するために、これらに対処する必要があります。

確認すべき一般的な問題

1. 空の Catch ブロック

❌ try {
     await submitForm();
   } catch (error) {
     // サイレントな失敗 - ユーザーは何もわからない
   }

✅ try {
     await submitForm();
   } catch (error) {
     console.error('Form submission failed:', error);
     setError('Could not submit. Please try again.');
   }

2. クリーンアップのための Finally の欠落

❌ try {
     setLoading(true);
     await fetchData();
     setLoading(false);
   } catch (error) {
     handleError(error);
     // ローディングが永遠に true のまま!
   }

✅ try {
     setLoading(true);
     await fetchData();
   } catch (error) {
     handleError(error);
   } finally {
     setLoading(false);
   }

3. 技術的なエラーの公開

❌ catch (error) {
     setError(error.message);
     // ユーザーには "TypeError: Cannot read property 'map' of undefined" が表示される
   }

✅ catch (error) {
     console.error('Load failed:', error);
     setError('Something went wrong. Please try again.');
   }

4. エラーの区別がない

❌ catch (error) {
     setError('Error');
   }

✅ catch (error) {
     if (error.status === 401) {
       setError('Please log in to continue.');
       redirectToLogin();
     } else if (error.status === 404) {
       setError('Item not found.');
     } else if (error.name === 'NetworkError') {
       setError('Check your internet connection.');
     } else {
       setError('Something went wrong. Please try again.');
     }
   }

ソクラテス式エラー質問

修正点を指摘する代わりに、次のように質問します。

  1. 「ユーザーがこれをクリックしたときにネットワークがダウンした場合、何が起こりますか?」
  2. 「この catch ブロックが実行された場合、ユーザーには何が表示されますか?」
  3. 「本番環境でこれが失敗したことをどのように知りますか?」
  4. 「一部のアイテムのみが保存に失敗した場合はどうなりますか?」
  5. 「エラーが発生した場合、ローディングスピナーは停止しますか?」

エラーメッセージ品質チェック

悪いメッセージ より良いメッセージ
"Error" "保存できませんでした。もう一度お試しください。"
"An error occurred" "プロファイルをロードできません。接続を確認してください。"
"TypeError: undefined" "問題が発生しました。リフレッシュしてもう一度お試しください。"
"500 Internal Server Error" "サーバーで問題が発生しています。しばらくしてからもう一度お試しください。"
"Failed" "リクエストを完了できませんでした。サポートが必要ですか?サポートにお問い合わせください。"

重大度ガイド

問題 重大度 影響
空の catch ブロック HIGH サイレントな失敗、デバッグが困難
ローディング状態のクリーンアップがない MEDIUM UI が停止する、UX が悪い
技術的なエラーが表示される MEDIUM UX が混乱する、情報漏洩の可能性
リトライオプションがない LOW UX のわずかな摩擦
一般的なエラーメッセージ LOW あまり役に立たないが、壊れてはいない
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Gate 3: Error Handling Review

"Happy path code is easy. Error handling is where senior engineers shine."

Purpose

This gate ensures the code handles failures gracefully, provides meaningful feedback to users, and doesn't silently swallow errors.

Gate Status

  • PASS — Error handling is appropriate
  • WARNING — Issues found that should be addressed

Gate Questions

Question 1: Failure Scenario

"What happens if [main operation] fails? Walk me through the user experience."

Looking for:

  • Awareness of failure modes
  • User-friendly error messages
  • Recovery options (retry, fallback)
  • No silent failures

Example scenarios:

  • Network request fails
  • Database is down
  • Validation fails
  • Third-party API errors

Question 2: User Feedback

"What does the user see when an error occurs? Would they understand what to do next?"

Looking for:

  • Helpful, non-technical messages
  • Actionable guidance ("Try again", "Check your connection")
  • Appropriate error placement in UI

Question 3: Error Visibility

"How would you debug this in production if something went wrong?"

Looking for:

  • Errors are logged
  • Sufficient context in logs
  • No sensitive data in logs
  • Error tracking awareness (Sentry, etc.)

Error Handling Checklist

Async Operations

  • [ ] All async calls wrapped in try/catch or .catch()
  • [ ] No empty catch blocks
  • [ ] Errors include context (what operation, what data)
  • [ ] finally blocks for cleanup (loading states, etc.)

User Experience

  • [ ] User-friendly error messages (no technical jargon)
  • [ ] Errors are actionable (what can user do?)
  • [ ] Loading states cleared on error
  • [ ] Retry options where appropriate

Logging & Debugging

  • [ ] Errors logged with context
  • [ ] No sensitive data in error logs
  • [ ] Error types/codes for categorization
  • [ ] Stack traces available in development

Edge Cases

  • [ ] Empty states handled
  • [ ] Timeout handling
  • [ ] Partial failure handling (some items succeed, some fail)
  • [ ] Concurrent request handling

Response Templates

If PASS

✅ ERROR HANDLING GATE: PASSED

Error handling looks solid:
- Async operations properly wrapped
- User-friendly error messages
- Errors logged for debugging

Moving to the next gate...

If WARNING

⚠️ ERROR HANDLING GATE: WARNING

Found [X] error handling concerns:

**Issue 1: [Empty catch block / Missing error handling]**
Location: `file.ts:42`
Question: "What happens when this fails silently?"

**Issue 2: [Technical error shown to user]**
Location: `file.ts:88`
Question: "Will users understand 'TypeError: Cannot read property...'?"

**Issue 3: [No loading state cleanup]**
Location: `file.ts:100`
Question: "What happens to the loading spinner if this fails?"

These should be addressed to ensure a good user experience.

Common Issues to Check

1. Empty Catch Blocks

❌ try {
     await submitForm();
   } catch (error) {
     // Silent failure - user has no idea
   }

✅ try {
     await submitForm();
   } catch (error) {
     console.error('Form submission failed:', error);
     setError('Could not submit. Please try again.');
   }

2. Missing Finally for Cleanup

❌ try {
     setLoading(true);
     await fetchData();
     setLoading(false);
   } catch (error) {
     handleError(error);
     // Loading stays true forever!
   }

✅ try {
     setLoading(true);
     await fetchData();
   } catch (error) {
     handleError(error);
   } finally {
     setLoading(false);
   }

3. Technical Errors Exposed

❌ catch (error) {
     setError(error.message);
     // User sees: "TypeError: Cannot read property 'map' of undefined"
   }

✅ catch (error) {
     console.error('Load failed:', error);
     setError('Something went wrong. Please try again.');
   }

4. No Error Differentiation

❌ catch (error) {
     setError('Error');
   }

✅ catch (error) {
     if (error.status === 401) {
       setError('Please log in to continue.');
       redirectToLogin();
     } else if (error.status === 404) {
       setError('Item not found.');
     } else if (error.name === 'NetworkError') {
       setError('Check your internet connection.');
     } else {
       setError('Something went wrong. Please try again.');
     }
   }

Socratic Error Questions

Instead of pointing out the fix, ask:

  1. "What happens if the network is down when the user clicks this?"
  2. "If this catch block runs, what will the user see?"
  3. "How will you know this failed in production?"
  4. "What if only some of the items fail to save?"
  5. "Is the loading spinner stuck if an error happens?"

Error Message Quality Check

Bad Message Better Message
"Error" "Could not save. Please try again."
"An error occurred" "Unable to load your profile. Check your connection."
"TypeError: undefined" "Something went wrong. Please refresh and try again."
"500 Internal Server Error" "Our servers are having trouble. Please try again in a moment."
"Failed" "Could not complete your request. Need help? Contact support."

Severity Guide

Issue Severity Impact
Empty catch block HIGH Silent failures, hard to debug
No loading state cleanup MEDIUM Stuck UI, poor UX
Technical error shown MEDIUM Confusing UX, potential info leak
No retry option LOW Minor UX friction
Generic error message LOW Less helpful but not broken