Under heavy development
StitchAPI

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

See also

On this page