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
Types
kind Values
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
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() for the full contract.
app/.server/context.ts
Example
Pilot turns aWeaverseLoadError 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:
app/weaverse/load-failure.ts
app/.server/context.ts
throwRouteFailures is Pilot’s helper, not an SDK export. The root ErrorBoundary reads weaverseFailure from the thrown response to render a “try again” page.
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.