SDK reference
Error types
The typed errors the SDK throws, and how to branch on them.
Every SDK error extends GateError, so a single instanceof GateError catches all of them.
Branch on the specific subclasses when you need the detail.
import {
GateError,
GateApiError,
ApprovalRejectedError,
ApprovalExpiredError,
ApprovalPendingError,
WebhookVerificationError,
} from "@seal-dev/sdk";| Error | Thrown by | Extra properties |
|---|---|---|
GateError | base class — never directly | — |
GateApiError | any non-2xx API response | status: number, body: unknown |
ApprovalRejectedError | require() on rejection | approval: ApprovalRequestView, feedback: string | null |
ApprovalExpiredError | require() on expiry | approval: ApprovalRequestView |
ApprovalPendingError | require() on client timeout / abort | approval: ApprovalRequestView |
WebhookVerificationError | verifyWebhook() on any failure | — |
Branching
import { gate } from "./gate.js";
import { ApprovalRejectedError, ApprovalExpiredError, ApprovalPendingError } from "@seal-dev/sdk";
try {
const approval = await gate.require(input, { timeoutMs: 60_000 });
await act(approval);
} catch (err) {
if (err instanceof ApprovalRejectedError) {
// A human said no. err.feedback carries their reason.
} else if (err instanceof ApprovalExpiredError) {
// Nobody decided in time; the policy's onTimeout applied.
} else if (err instanceof ApprovalPendingError) {
// Still pending after your client deadline — resume later with the id.
await scheduleRecheck(err.approval.id);
} else {
throw err;
}
}ApprovalPendingError does not mean the request failed — it means your client stopped waiting.
The request is still live on the server; poll it again with
gate.resume(id).