---
title: "Errors"
description: "Throw, log, serialize, and parse Blyp errors on the server and in the browser."
canonical_url: "https://www.blyp.dev/docs/errors"
markdown_url: "https://www.blyp.dev/docs/errors.md"
last_updated: "2018-10-20"
x_farming_labs_generated_preamble: true
---

# Errors
URL: /docs/errors
LLM index: /llms.txt
Description: Throw, log, serialize, and parse Blyp errors on the server and in the browser.

# Errors

Blyp error handling revolves around three pieces:

- [`createError()`](/docs/errors/create-error) for building and optionally logging a `BlypError`
- [`parseError()`](/docs/errors/parse-error) for hydrating unknown payloads or `Response` objects back into a `BlypError`
- [`HTTP_CODES`](/docs/errors/http-codes) for reusable status presets and custom error families

## Choose the right entry point

| Need | Use |
| --- | --- |
| Create a brand-new structured application error | [`createError()`](/docs/errors/create-error) |
| Normalize a failed `fetch()` response or foreign payload | [`parseError()`](/docs/errors/parse-error) |
| Reuse a status preset or define a shared domain error | [`HTTP_CODES`](/docs/errors/http-codes) |

## Shared error shape

A `BlypError` can carry more than a message:

- `status`
- `code`
- `message`
- `why`
- `fix`
- `link`
- `details`

That makes the same error useful for runtime logging, API responses, and operator-facing debugging.

## Typical flow

1. Build a first-party failure with [`createError()`](/docs/errors/create-error) or normalize an external one with [`parseError()`](/docs/errors/parse-error).
2. Throw or return the resulting `BlypError`.
3. Reuse [`HTTP_CODES`](/docs/errors/http-codes) when the same pattern appears across multiple handlers or services.

## What a `BlypError` looks like end to end

**Code:**

```ts
throw createError({
  status: 402,
  message: "Payment failed",
});
```

**What Blyp logs:**

```text
[ERROR] Payment failed
  status=402 type=BlypError
```

**HTTP response body:**

```json
{
  "status": 402,
  "message": "Payment failed"
}
```

## `parseError()` output

```ts
const parsed = parseError(err);
```

**Result shape:**

```json
{
  "status": 500,
  "message": "Unexpected token in JSON",
  "type": "SyntaxError",
  "stack": "SyntaxError: Unexpected token...\\n    at JSON.parse (<anonymous>)"
}
```

## Read next

- [createError](/docs/errors/create-error)
- [parseError](/docs/errors/parse-error)
- [HTTP Codes](/docs/errors/http-codes)

## Sitemap

See the full [sitemap](/sitemap.md) for all pages.
Docs-scoped sitemap: [/docs/sitemap.md](/docs/sitemap.md).
Well-known sitemap: [/.well-known/sitemap.md](/.well-known/sitemap.md).
