Errors and production checks
API errors
ApiError exposes status, code, message, requestId, retryAfterMs and response headers. Transport failures use status 0, so it is not always a valid HTTP response status for your own proxy.
import { ApiError, createT3trisClient } from "@t3tris-labs/sdk";
const client = createT3trisClient({ apiKey: process.env.T3TRIS_API_KEY });
export async function loadVaults(): Promise<Response> {
try {
return Response.json(await client.vaults.list({ limit: 20 }));
} catch (error) {
if (!(error instanceof ApiError)) throw error;
return Response.json({
error: { code: error.code, message: error.message, requestId: error.requestId },
}, { status: error.status >= 400 ? error.status : 502 });
}
}
| Status/code | Check |
|---|---|
400 | Invalid inputs or attachment quota |
401 | Missing/revoked key or an invalid user session |
403 | Scope or identity permission is insufficient |
404 | Resource is unknown, hidden or unavailable to this key |
409 | Conflicting resource update |
429 | Request rate or current-cycle usage cap |
5xx | Upstream service failure |
0 / network_error | Connection failed before an HTTP response |
0 / timeout | Request exceeded its deadline |
0 / aborted | Caller cancelled the request |
invalid_response | Response was not valid JSON, even if its HTTP status was successful |
For 429, respect retryAfterMs when provided and inspect usage in Curate or billing.getUsage. A monthly cap will not be fixed by a rapid retry loop. Preserve requestId for support, but redact credentials and personal data from logs.
Client requestOptions.retries is opt-in. It retries safe GET network/server failures only. Writes are never retried automatically, and 429 needs application-level handling. A timed-out mutation may already have reached the server: read back state before deciding to retry.
Wallet errors
import { ActionCancelledError, ChainMismatchError, PlatformActionError } from "@t3tris-labs/sdk";
export function actionMessage(error: unknown): string {
if (error instanceof ActionCancelledError) return "Request cancelled in your wallet.";
if (error instanceof ChainMismatchError)
return `Select chain ${error.expectedChainId} before retrying.`;
if (error instanceof PlatformActionError)
return error.code ?? error.message;
return "Action failed. Review the wallet and contract state before retrying.";
}
PlatformActionError may include code, selector and revertData. Some contract failures have no decoded code. A failed simulation submits no transaction, while a lost RPC response after broadcasting can leave execution uncertain. Inspect the wallet and chain before asking for another submission.
Do not automatically retry transactions, switch funding paths after rejection, or use unsafe: true to suppress a contract failure. Network changes and permission changes need a fresh user review.
Production checklist
- Pin the SDK revision and commit the lockfile. Review its changelog before upgrading.
- Keep API keys and SDK session tokens server-side. Validate inputs, authorize your own routes and protect cookie-backed writes against CSRF.
- Use separate credentials per environment or integration. Grant
manageonly where needed and rotate/revoke compromised keys in Curate. - Verify chain, factory, token, vault and oracle addresses. Recreate wallet clients when the account or network changes.
- Parse user amounts using token decimals, preserve bigint precision and distinguish API basis points from contract WAD.
- Show approvals, permits, proposed transactions and executed transactions as separate stages. Never report success from a proposal ID alone.
- Wait for receipts and handle reverts. Verify important postconditions with contract reads before relying on indexed API data.
- Handle missing price/APY/composition fields and indexer delays without inventing values.
- Persist event checkpoints after processing and make handlers safe to replay. Abort streams on shutdown.
- Test wrong-network errors, rejected signatures, expired sessions,
403,429, insufficient allowance, failed simulations and Safe proposal execution on an isolated fork before accepting funds.
Read the protocol's security information and the relevant vault's risks as part of the integration review.