Error Handlingのロゴ

Error Handling

組織人気
EpicenterHQ
error-handling

エラー処理、Wellcrafted Results、結果型、defineErrors、trySync、tryAsync、unwrap、例外のスロー、または失敗を伝播させるか、復旧するか、提示するかの判断に関するタスクで使います。診断情報の記録にはloggingを、キャッシュのライフサイクルにはquery-layerを使ってください。

Add to TypingMind

概要

公開者EpicenterHQ
リポジトリepicenter
スキル名error-handling
スター
4.8K
フォーク
386
同梱ファイル
4
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 4個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    EpicenterHQがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Error Handling」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/EpicenterHQ/epicenter/tree/main/.agents/skills/error-handling
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/EpicenterHQ/epicenter.git /tmp/epicenter
mkdir -p .claude/skills
cp -r /tmp/epicenter/.agents/skills/error-handling .claude/skills/error-handling
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでError Handlingを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にError Handlingを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Error Handlingは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

Error Handling

Epicenter uses Wellcrafted Results as its internal contract for ordinary failures. This skill owns the full path: define a tagged failure, adapt a throwing dependency, compose or recover from Results, then consume the outcome at the boundary that serves a person or another API. Use logging for diagnostics, query-layer for TanStack observation and cache behavior, and hono for HTTP response mechanics.

Source Of Truth

Ground every Wellcrafted behavior claim in the official wellcrafted-dev/wellcrafted source and tests. When maintaining this guidance, confirm that Epicenter's installed version matches the source being read. If it does not, report the version drift; dependency freshness is handled outside this skill. Treat other skills, examples, generated documentation, and DeepWiki as leads, not authority.

Read the scoped references only when needed:

Carry the outcome until a caller settles it

Fallible application work returns Result<T, E> while its caller can recover, add context, or choose how to present the outcome. Compose operations by handling or forwarding each possible Err. Preserve a lower error unless the current operation owns a meaningful new failure. An intentional fallback can return Ok, and a partial success may need success data that records what degraded, so the final caller can respond accurately.

The interaction owner consumes the final outcome into UI state, a toast, an HTTP response, or another host contract. That owner is determined by responsibility and lifetime, not by whether the code lives in an onclick attribute or an operations directory. A terminal action can return void or Promise<void> after settling the outcome. Infallible work stays plain, and unexpected bugs must not become routine Err values.

Do not treat every consumption boundary as an unwrap. Branch on the Result when the caller presents or recovers from an error. Use unwrap when the receiving API already communicates failure by throwing.

Choose The Contract First

Required contractPattern
Callee already returns Result<T, E>Inspect or forward its Err; do not wrap the call in trySync or tryAsync
Callee throws but caller needs Result<T, E>Adapt the throwing operation with trySync or tryAsync
Failure has a valid fallbackReturn Ok(fallback) from catch
Failure must propagate as dataReturn a typed defineErrors factory result from catch
Only known external failures should become ErrMap known exceptions and rethrow unknown ones
Surrounding API is exception-basedKeep its throwing contract
Cleanup must run on success, failure, cancellation, or early returnUse finally

Use trySync for a synchronous operation and tryAsync for an operation returning a Promise.

ts
const { data: response, error } = await tryAsync({
	try: () => fetch(url),
	catch: (cause) => RequestError.TransportFailed({ cause }),
});
if (error !== null) return Err(error);
return Ok(response);

defineErrors factories already return Err(...). Pass the raw cause into the factory and let the factory compose its message with extractErrorMessage. Do not use raw Err(cause) at a catch boundary: thrown values may be null or undefined, and an untyped cause loses the domain failure.

Cross a deliberate throwing boundary

Keep a Result as data while the caller can still recover, report, retry, or propagate. Use unwrap only where the surrounding API already throws as its failure channel:

ts
import { unwrap } from 'wellcrafted/result';

const document = unwrap(await openDocument(id));

unwrap returns Ok.data and throws Err.error. The throw is the boundary's contract, not a sign the failure was unexpected. Guard on error !== null instead when this function must recover, add context, or clean up.

A conceptual sketch is the one exception: unwrap may stand in for Result branches that do not change the behavior being explained. Say that the sketch throws on failure, and show the branch whenever a failure changes that behavior, such as keeping an unsaved draft after a save conflict.

Consume Every Possible Err Branch

  • If a value can be Result<T, E>, inspect or deliberately forward its error branch.
  • After destructuring, error is the raw E. Return Err(error), not error.
  • If you retained the whole Result, return it unchanged: if (result.error !== null) return result.
  • error !== null is the reliable discriminator. Never construct Err(null) or Err(undefined).
  • Data-only destructuring is correct when the catch branch always returns Ok<T> and the inferred type collapses to Ok<T>.
  • Error-only destructuring is correct when success data is irrelevant. The rule is to handle every possible Err, not to destructure fields you do not use.

Prefer an immediate guard so the success path stays linear.

When a caller translates every variant of a tagged error union, use an exhaustive switch (error.name) with default: error satisfies never. A guard for one variant followed by a shared path is different. See error variants for both shapes.

Own The Promise

tryAsync returns a Promise. Choose its owner explicitly:

  • await when this function inspects the Result.
  • return tryAsync(...) when the caller owns the Promise<Result<...>>.
  • Do not use bare void tryAsync(...): ordinary failures fulfill with Err, so a Promise rejection handler cannot observe them. A best-effort operation still needs an async owner that awaits the Result and explicitly logs or ignores its error branch.
  • In UI fire-and-forget code, attach presentation before discarding a Promise that fulfills with a Result: void save().then((result) => toastOnError(result, 'Save failed')). If the Promise can reject, adapt or catch that rejection first.

Keep Native Try-Catch When It Expresses The Contract

Traditional try-catch is appropriate when:

  • a finally block owns cleanup;
  • a generator must yield a failure rather than return a Result;
  • a framework boundary converts an exception directly into its required response shape;
  • code catches one known exception and rethrows everything else;
  • the surrounding public API intentionally throws.

Do not turn unknown programming errors into a generic domain failure. Mapping every throw to Err can hide bugs behind a misleading retryable error.

Final Check

  1. The function's throw-versus-Result contract is explicit.
  2. The wrapper covers one coherent failure meaning.
  3. Caught values become typed errors, intentional fallbacks, or selective rethrows.
  4. Every possible Err branch is handled, forwarded, logged, presented, or explicitly ignored by a named best-effort owner.
  5. Unknown bugs still reach the appropriate crash or framework error boundary.

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「Error Handling」では何ができますか?

エラー処理、Wellcrafted Results、結果型、defineErrors、trySync、tryAsync、unwrap、例外のスロー、または失敗を伝播させるか、復旧するか、提示するかの判断に関するタスクで使います。診断情報の記録にはloggingを、キャッシュのライフサイクルにはquery-layerを使ってください。

TypingMindでError Handlingを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Error Handlingはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにError Handlingをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/EpicenterHQ/epicenter/tree/main/.agents/skills/error-handlingを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Error Handlingを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Error Handlingで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもError Handlingを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Error Handling」は無料ですか?

EpicenterHQがGitHubで公開しています。ライセンス条件はリポジトリでご確認ください。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇