> ## Documentation Index
> Fetch the complete documentation index at: https://weaverse.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Weaverse component configuration uses `settings`. `inspector` is deprecated; never generate it.
> Weaverse Hydrogen themes use React Router v7: import from `react-router`, never `react-router-dom` or `@remix-run/*`.
> Before using any code sample, read `@weaverse/hydrogen` in the project's `package.json`: 6.x and 5.x import from different entries and use different type names, so code for one does not build on the other.
> `@weaverse/hydrogen` 6 (Shopify Hydrogen 2026.10 and later, the version these docs show) imports from `@weaverse/hydrogen/react-router` and uses `Weaverse*` types such as `WeaverseComponentProps`, `WeaverseComponentLoaderArgs` and `WeaverseComponentSchema`; the root `@weaverse/hydrogen` entry only exports `createSchema()`, data helpers and types.
> `@weaverse/hydrogen` 5.x (Hydrogen 2026.4 and earlier) imports everything from `@weaverse/hydrogen` and uses `HydrogenComponentProps`, `ComponentLoaderArgs` and `HydrogenComponentSchema`. On a 5.x project, convert samples to these names. Upgrade to 6 only when asked (`npx @weaverse/cli@latest migrate v6`, plus the Hydrogen 2026.10 upgrade). Do not mix major versions.
> Next.js themes use `@weaverse/hydrogen` 6.2.0 or later: import client and shared code from `@weaverse/hydrogen/next` and server-only code from `@weaverse/hydrogen/next/server`. `@weaverse/next` is deprecated; never install or import it.
> For live project data (pages, theme settings, translations), use the Weaverse MCP server: https://weaverse.io/docs/developer-tools/weaverse-mcp

# WeaverseError and WeaverseLoadError

> Error classes thrown by the Weaverse SDK, and how to tell a Weaverse outage from a missing page with WeaverseLoadError's kind.

# WeaverseError and WeaverseLoadError

`WeaverseError` is the base class for errors the SDK throws. `WeaverseLoadError` extends it for page loads that failed, as opposed to pages that don't exist. Its `kind` tells a route whether to answer with a retryable error or a configuration error.

## Import

```tsx theme={null}
import {
  WeaverseError,
  WeaverseLoadError,
  type WeaverseLoadFailureKind,
} from '@weaverse/hydrogen/react-router'
```

## Types

```typescript theme={null}
class WeaverseError extends Error {
  /** Machine-readable error code, e.g. `ASYNC_PROJECT_ID`. Default `WEAVERSE_ERROR`. */
  readonly code: string
  /** HTTP status associated with the failure, when available. */
  readonly statusCode?: number
  /** Structured diagnostic details for logging. */
  readonly context?: Record<string, unknown>
}

class WeaverseLoadError extends WeaverseError {
  /** Always `LOAD_FAILURE`. */
  readonly code: string
  readonly kind: WeaverseLoadFailureKind
}

type WeaverseLoadFailureKind = 'unavailable' | 'invalid-response' | 'configuration'
```

## `kind` Values

| `kind` | Meaning | Suggested response |
| - | - | - |
| `unavailable` | The Weaverse API timed out, couldn't be reached, or answered with a transient status (408, 425, 429 or 5xx) after the built-in retry. | `503`, not cached. Retrying later can succeed. |
| `invalid-response` | The API answered successfully, but the body isn't a page/project envelope. | `503`, not cached. |
| `configuration` | The request was refused or couldn't be built: an invalid per-call `projectId` passed to `loadPage()`, or a 400/401/403 from the API. | `500`. Retrying won't help. |

## When It's Thrown

`WeaverseClient.loadPage()` throws `WeaverseLoadError` only when the client is created with `throwPageLoadFailures: true`. With the default (`false`), a failed load resolves to `null`, the same value a nonexistent project produces, so a route can't tell an outage from a 404. One exception: an HTTP 200 whose body isn't a page envelope (for example `{}`) resolves to the fallback placeholder page, which looks like a route with nothing assigned. Turn the option on when you need to tell an invalid response from an absent page.

A missing page is never an error. With or without the option:

* a nonexistent project (a 404 from the Weaverse API) resolves to `null`
* a route with no page assigned in Studio resolves to a fallback placeholder page

A client that can't resolve a project ID at all is a setup error, not a load failure: the `WeaverseClient` constructor throws a plain `WeaverseError` with code `MISSING_PROJECT_ID` (or `INVALID_PROJECT_ID` for a malformed `projectId` argument), whatever `throwPageLoadFailures` is set to.

See [`loadPage()`](https://weaverse.io/docs/api-reference/weaverse-client#loadpage) for the full contract.

```ts app/.server/context.ts theme={null}
const weaverse = new WeaverseClient({
  storefront,
  env,
  cache,
  waitUntil,
  request,
  themeSchema,
  components,
  throwPageLoadFailures: true,
});
```

## Example

Pilot turns a `WeaverseLoadError` into a route response, so a Weaverse outage answers `503` instead of a `404` that crawlers treat as a deleted page. It wraps `loadPage` once where the client is created (`app/weaverse/load-failure.ts`), so every route gets the behavior:

```ts app/weaverse/load-failure.ts theme={null}
import { type WeaverseClient, WeaverseLoadError } from '@weaverse/hydrogen/react-router'
import { data } from 'react-router'

const NO_STORE = { 'Cache-Control': 'no-store' }

export function weaverseRouteFailure(error: unknown): unknown {
  if (!(error instanceof WeaverseLoadError)) {
    return error
  }
  const retryable = error.kind !== 'configuration'
  return data(
    { weaverseFailure: retryable ? 'unavailable' : 'error' },
    { status: retryable ? 503 : 500, headers: NO_STORE },
  )
}

export function throwRouteFailures(client: WeaverseClient): WeaverseClient {
  const loadPage = client.loadPage
  client.loadPage = async (params) => {
    try {
      return await loadPage(params)
    } catch (error) {
      throw weaverseRouteFailure(error)
    }
  }
  return client
}
```

```ts app/.server/context.ts theme={null}
const weaverse = throwRouteFailures(
  new WeaverseClient({ /* ... */ throwPageLoadFailures: true }),
)
```

`throwRouteFailures` is Pilot's helper, not an SDK export. The root `ErrorBoundary` reads `weaverseFailure` from the thrown response to render a "try again" page.

> [!NOTE]
>
> `WeaverseError` and `WeaverseLoadError` are also exported from `@weaverse/hydrogen/next`. The Next.js server client catches page-load failures and resolves `loadPage()` to `null`; it has no `throwPageLoadFailures` option.

## Related

* [WeaverseClient](https://weaverse.io/docs/api-reference/weaverse-client.md)
* [Rendering a Weaverse Page](https://weaverse.io/docs/guides/rendering-page.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.