# errors

Stable error vocabulary: responsibilities, supported exports and extension points.

## Purpose [#purpose]

Client-safe codes and resolvers (`translateError`, `resolveErrorMessage`, `getFieldErrors`) turn transport errors into localized messages. Leaf policy subpaths share the mutation-toast rule (`./mutation-toast`), the TanStack Query retry policy (`./query-retry`), what a client does with a failed collection write (`./write-outcome`), and which kind of error an error screen shows, with whether it offers "Report a problem" (`./error-kind`), across web and mobile. Server handling logs unexpected failures and maps known errors to oRPC responses. Auth-client helpers interpret Better Auth errors.

## Public exports [#public-exports]

| Subpath               | Target                       |
| --------------------- | ---------------------------- |
| `.`                   | `./src/index.ts`             |
| `./auth-client-error` | `./src/auth-client-error.ts` |
| `./error-kind`        | `./src/error-kind.ts`        |
| `./locales`           | `./src/locales/index.ts`     |
| `./mutation-toast`    | `./src/mutation-toast.ts`    |
| `./query-retry`       | `./src/query-retry.ts`       |
| `./server`            | `./src/server.ts`            |
| `./write-outcome`     | `./src/write-outcome.ts`     |

These paths come from `packages/errors/package.json`. A `.` entry is the package root. Conditional targets distinguish platform or type resolution; consumers should import the subpath, not its source file.

## How to extend [#how-to-extend]

Introduce a stable code and catalog messages for an actionable new failure. Preserve its typed path across the boundary; do not display raw database/provider exception text.

Read the [stable error vocabulary guide](/docs/architecture/observability) for the full flow.

## Key files [#key-files]

- [`packages/errors/package.json`](https://github.com/CarlosZiegler/fofo/blob/main/packages/errors/package.json)
