Skip to content
Agentmart
Submit a tool

autotel-structured-errors

Throws and parses errors that explain themselves with message, why, fix, link, and status, including reusable catalogs via defineErrorCatalog.

Skill by jagreehal

IndexedApache-2.0★ 8
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/jagreehal-autotel-structured-errors

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Throws and parses errors that explain themselves with message, why, fix, link, and status, including reusable catalogs via defineErrorCatalog. Use this skill when writing API-route errors, surfacing an API error in UI with parseError, or folding repeated inline errors into one catalog. Do not use for recording an already-caught error on a span — skill autotel-request-logging covers .error() — or for audit and security events, which skill build-audit-trails covers.

Use cases: design, backend, security, writing

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md and code. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/autotel-structured-errors

What's inside

Skill name
autotel-structured-errors
Description
Throws and parses errors that explain themselves with message, why, fix, link, and status, including reusable catalogs via defineErrorCatalog. Use this skill when writing API-route errors, surfacing an API error in UI with parseError, or folding repeated inline errors into one catalog. Do not use for recording an already-caught error on a span — skill autotel-request-logging covers .error() — or for audit and security events, which skill build-audit-trails covers.
License
Apache-2.0
Instructions
163 lines in SKILL.md · view on GitHub

Before installing

  • Instructions call the network

Files (1)

  • SKILL.md

SKILL.md (first lines)

# Autotel: Structured Errors

Throw errors with `createStructuredError({ message, why?, fix?, link?, status?, cause? })` in API routes and services. On the client, use `parseError(caught)` to get `message`, `status`, `why`, `fix`, `link` for toasts and UI.

## Setup

**Server (API route or service):**

```typescript
import { createStructuredError } from 'autotel';

if (!user) {
  throw createStructuredError({
    message: 'User not found',
    status: 404,
    why: `No user with ID "${userId}"`,
    fix: 'Check the user ID and try again',
    link: 'https://docs.example.com/errors/user-not-found',
  });
}
```

**Client:**

```typescript
import { parseError } from 'autotel';

try {
  await fetch('/api/checkout', { method: 'POST', body: JSON.stringify(data) });
} catch (err) {
  const e = parseError(err);
  toast.error(e.message, { description: e.why });
  if (e.fix) setHelp(e.fix);
  if (e.link) setDocLink(e.link);
}
```

## Core Patterns

**Wrap a caught error (preserve cause):**

```typescript
try {
  await stripe.charges.create(data);
} catch (err) {
  throw createStructuredError({
    message: 'Payment failed',
    status: 402,
    why: err instanceof Error ? err.message : 'Unknown error',
    fix: 'Try a different payment method or contact support',
    link: 'https://docs.stripe.com/declines',
    cause: err,
  });
}
```

**Same error from several places:** define it once with `defineErrorCatalog` instead of copying the wording.

```typescript
import { defineErrorCatalog } from 'autotel';

export const billing = defineErrorCatalog('billing', {
  PAYMENT_DECLINED: {
    status: 402,
    message: 'Card declined',
    why: 'The issuer rejected the charge',
    fix: 'Try a different payment method',
  },
  INSUFFICIENT_FUNDS: {
    status: 402,
    message: ({
      available,
      required,
    }: {
      available: number;
      required: number;
    }) => `Insufficient funds: $${available} of $${required}`,
  },
});

throw billing.PAYMENT_DECLINED({ cause: stripeError });
throw billing.INSUFFICIENT_FUNDS({ available: 5, required: 100 });

if (billing.PAYMENT_DECLINED.match(err)) retryWithDifferentCard();
```

Builders return the same `StructuredError`, so `parseError()` still works. Codes default to `namespace.KEY`. A function `message` or `why` takes typed params enforced at every call site. `.match()` compares the catalog code, so renaming an entry breaks the compile instead of skipping the branch.

**Record on current span:** `createStructuredError()` only builds the error; it touches no span. Thrown out of a `trace()` body, it sets the span's ERROR status and records the exception. The structured fields (`error.why`, `error.fix`, `error.link`, `error.code`, `error.status`) reach the span only through `recordStructuredError(ctx, error)` or the request logger's `.error(error, fields)`:

```typescript
import { recordStructuredError } from 'autotel';

catch (err) {
  const e = billing.PAYMENT_DECLINED({ cause: err });
  recordStructuredError(ctx, e); // or getRequestLogger().error(e)
  throw e;
}
```

For new exception event flows, prefer request-logger/log-based correlation and keep span-event compatibility as an implementation detail (processors/export path), not a new app-level dependency.

**parseError** handles FetchError (ofetch), nested `data.data`, and plain Error. Returns `{ message, status, why?, fix?, link?, raw }`.

## Common Mistakes

### HIGH Throw new Error() in API routes instead of createStructuredError

Wrong:

```typescript
throw new Error('Payment failed');
```

Correct:

```typescript
throw createStructuredError({
  message: 'Payment failed',

From jagreehal/autotel, Apache-2.0.

More from jagreehal/autotel

Signals

Stars
8
Forks
3
Open issues
0
Last commit (this folder)
Oct 19, 2026 (8 days ago)
Last release
Sep 27, 2026 (1 month ago)

From GitHub (fetched Oct 24, 2026).

Details

License
Apache-2.0
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from jagreehal

Cite this page

autotel-structured-errors skill. Agent Mart. https://agentmart.dev/skills/jagreehal-autotel-structured-errors (last updated 2026-10-24)