ChipiApiError with a usable status code; missing resources return null (not a throw) where it makes sense. This page walks the patterns you’ll actually hit.
The error hierarchy
Concrete classes live in@chipi-stack/shared and all extend a base ChipiError:
ChipiError has .code (string) and .message. ChipiApiError carries .status (HTTP status code) — its constructor requires it, though the inherited type makes it optional, so devs reading the field still need a fallback (err.status ?? 500) to satisfy strict TypeScript. Use instanceof for type narrowing or pattern-match on .code / .name / .status.
Constructor validation
TheChipiServerSDK constructor throws synchronously on bad config — before any network call. This is intentional: catch typos in your env vars at boot, not at first request.
API-level rejections
API calls throwChipiApiError (or one of the more specific subclasses) when the server returns a non-2xx. The status field tells you which HTTP code — branch on it.
getWallet returns null, doesn’t throw
For lookups that “might not exist”, the SDK returns null rather than throwing. This is true for getWallet — wrap your code accordingly:
null is a happy-path signal here, not an error. The same call only throws if the API itself failed (auth, network, 5xx) — which you’d catch with the ChipiApiError patterns above.
Invalid on-chain inputs throw before sending
Inputs that don’t pass on-chain validation (malformed addresses, unknown tokens) reject before the paymaster fires the transaction — you don’t pay gas for a rejected request.Putting it together
A small middleware that maps every Chipi error class to the right HTTP response:✅ Verified against the live API on 2026-05-11.
