agentsclimarketplace

1natsu error handling

Skill 1natsu-vacation/agent-skills/skills/1natsu-error-handling

エラーハンドリングの実装、try-catchブロックの記述、エラーハンドリング層の設計、エラー伝播のレビュー時に使用する。言語を考慮した構造的エラーハンドリングのガイドラインを提供する。From its SKILL.md

Install
npx -y skills add 1natsu-vacation/agent-skills --skill 1natsu-error-handling

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its file declares

Copied from the file, not written here

The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

3.9 KB, ~1.3k tokens by cl100k_base, as published. Nobody here has run it

エラーハンドリング ガイドライン

サイレントな失敗を防ぎ、適切なエラー伝播を保証するための構造的エラーハンドリングパターン。

いつ使うか

  • 任意の言語でエラーハンドリングを実装するとき
  • try-catch / try-except ブロックを書く・レビューするとき
  • エラーハンドリング層やミドルウェアを設計するとき
  • エラーの握りつぶしやハンドリング漏れをレビューするとき

原則

エラーを握りつぶさない

エラーは意味のあるハンドリングをするか、呼び出し元に伝播させなければならない。空のcatchブロックは禁止。

末端ではなく境界でハンドリングする

末端の関数(ビジネスロジック、ユーティリティ)はエラーをthrow/raiseすべき。キャッチするのはアーキテクチャの境界 — APIハンドラ、UIレイヤー、ジョブランナー、ミドルウェア — で構造的にハンドリングできる場所。

レイヤーごとに関心を分離する

  • ドメイン層: ドメイン固有のエラーをthrow
  • インフラ層: インフラのエラーをドメインエラーに変換
  • プレゼンテーション層: エラーをユーザー向けのレスポンスに変換

適切な粒度でキャッチする

大きなブロックを1つのtryで囲むのは避ける。tryブロックは小さく保ち、エラー発生箇所を明確にする。

カスタムエラー型を使う

型/クラスでエラーの種類を区別し、ハンドラが適切に分岐できるようにする。

ロギングとハンドリングを混同しない

ロギングはオブザーバビリティ。ハンドリングはアクション(リトライ、フォールバック、ユーザー通知)。両方とも境界のハンドラで行う — 各レイヤーで console.log してre-throwしない。

リソースのクリーンアップを保証する

finally / defer / with / using を使い、エラーパスでのリソースリークを防ぐ。

JavaScript / TypeScript

戦略

  • 末端の関数: エラーを検出して throw する。キャッチしない。
  • ミドルウェア / 境界: 集約ハンドラでエラーを構造的にキャッチする。
  • 非同期コード: async/await のエラーは必ず上流で try-catch または .catch() でハンドリングする。

アンチパターン

// BAD: 空のcatch — エラーを握りつぶしている
try {
  await fetchData();
} catch (e) {}

// BAD: console.logだけ — 実際のハンドリングがない
try {
  await fetchData();
} catch (e) {
  console.log(e);
}

// BAD: 末端でキャッチしてデフォルト値を返す — 呼び出し元がDBエラーとデータ不在を区別できない
async function getUser(id: string) {
  try {
    return await db.users.findById(id);
  } catch {
    return null;
  }
}

推奨パターン

// GOOD: 末端ではthrowし、エラーを伝播させる
async function getUser(id: string): Promise<User> {
  const user = await db.users.findById(id); // DBエラーは自然に伝播
  if (!user) {
    throw new NotFoundError(`User not found: ${id}`);
  }
  return user;
}

// GOOD: 境界で集約ハンドリング
app.use((err, req, res, next) => {
  if (err instanceof NotFoundError) {
    return res.status(404).json({ error: err.message });
  }
  logger.error(err);
  return res.status(500).json({ error: "Internal Server Error" });
});

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Gives 0 of the 12 instructions most error diagnosis skills give in ~1.3k tokens

Counted across 135 of the 162 authors here whose files we hold, read 2026-09-06

  • Handle, re-throw, or log in every catch blockin 12 of 135, across 7 files
  • Use typed error classes over string messagesin 11 of 135, across 6 files
  • Log full error context server-sidein 10 of 135, across 5 files
  • Document every error code clients may receivein 9 of 135, across 4 files
  • Surface errors at the boundary where they occurin 9 of 135, across 4 files
  • Wrap React components in an ErrorBoundaryin 9 of 135, across 4 files
  • Wrap errors with context, never lose the originalin 9 of 135, across 4 files
  • Use the standard error envelope for API responsesin 9 of 135, across 4 files
  • Retry only retriable errors, never 4xx client errorsin 8 of 135, across 3 files
  • Retry transient failures with exponential backoff and jitterin 8 of 135
  • Show users friendly messages without technical detailsin 7 of 135, across 3 files
  • Use the Result pattern for expected failuresin 7 of 135, across 5 files

Said here and by no other author read

  • Throw errors in leaf functions without catching
  • Keep try blocks small
  • Use custom error types to distinguish error kinds
  • Convert errors to user-facing responses in the presentation layer
  • Log and handle errors only at boundary handlers
  • Guarantee resource cleanup with finally, defer, with, or using

Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.