KitError, exported from
@circle-fin/app-kit. Its structured fields let you branch on the failure type
instead of parsing message strings. For a full integration walkthrough, see the
embed widget quickstart.
KitError fields
Prefer
type and recoverability for control flow. They are the stable,
forward-compatible contract. Use name and code only for exact matching,
logging, and telemetry.
Error handling
Catch aKitError and branch on type and recoverability to decide how to
recover:
TypeScript
Common error codes
HTTP status code mapping
createSessionRouteHandler maps thrown errors to HTTP status codes
automatically:
The handler also returns:
405 Method Not Allowedfor any method other thanPOST.400 Bad Requestif the body cannot be parsed as JSON.401 Unauthorizedif yourauthorizecallback returnsfalse.
KitError.cause for
diagnostic purposes.
Error sources
Runtime widget errors are surfaced through the
INITIALIZATION_ERROR event
rather than thrown. See
Handle lifecycle events.