Errors & pitfalls
How StitchAPI errors work, the code-to-docs contract, and an index of every coded failure.
When a stitch can't produce a result, it fails with a StitchError — an
Error with name: 'StitchError', a human-readable message, and an optional
.status carrying the upstream HTTP status. Await a stitch and that error is
what catch receives:
import { } from 'stitchapi';
const = ({
: 'https://api.example.com',
: '/me',
});
try {
await ();
} catch () {
if ( instanceof && . === 'StitchError') {
const = ( as Error & { ?: number }).;
.(., );
}
}If you read the event stream instead of awaiting,
the same failure arrives as an error event carrying
{ name, message, status?, attempts, at } — attempts is how many tries the
runtime made before giving up, at is when it gave up.
The code-to-docs contract
Each catalog page below owns a stable code (STITCH_VALIDATION,
STITCH_DRIFT, and so on). The code's page slug is its URL — the failure
documented at /errors/<slug> is the page the runtime will deep-link to from a
thrown error. Slugs are an API: once a page is published its slug is never
renamed, only added-and-redirected, so a link a runtime emitted a year ago still
resolves.
These codes are provisional. Today the runtime throws a StitchError
with a message and optional .status — the stable code and url fields
land with the error-taxonomy refactor. The slugs below are already fixed, so
you can rely on the URLs even while the in-runtime codes are still on the
way.
Every coded failure
STITCH_VALIDATION
A response failed its output schema — the shape you asked for isn't the shape you got.
STITCH_DRIFT
A response drifted from the schema past the level you allowed, so the stitch refused it.
STITCH_AUTH_WALL
Authentication failed, or a soft 200 login wall was hit and couldn't be refreshed.
STITCH_TIMEOUT
A call exceeded its timeout budget before a response arrived.
STITCH_CIRCUIT_OPEN
The circuit breaker is open after repeated failures and is short-circuiting calls.
STITCH_GRAPHQL
A GraphQL-over-HTTP response came back 200 but carried an errors
array.