EveryDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/anurag-roy/kiteconnect-ts/llms.txt
Use this file to discover all available pages before exploring further.
KiteConnect API method returns a Promise that can reject. When a request fails, the rejection value is a plain object — not a native Error instance — with a consistent shape that you can inspect to determine what went wrong and how to recover.
Error object structure
A rejected promise carries an object with three fields:error_type in your catch block to branch on specific failure modes.
Common error types
TokenException
The access token has expired or is invalid. This is the most common error in production. Use
setSessionExpiryHook to handle it automatically.DataException
The API returned an unrecognised content type. This usually means the upstream service returned an unexpected response format.
NetworkException
Either no response was received from the server, or the HTTP response had a non-2xx status code without a structured error body.
GeneralException
A catch-all for any other error that does not fit the categories above.
Handling errors in code
You can use eitherasync/await with try/catch or the Promise .catch() method. Both are equivalent.
Automatic session expiry handling
Rather than checking forTokenException manually in every call, register a single callback with setSessionExpiryHook. The client calls it automatically whenever a TokenException is received.
The session expiry hook is called in addition to the promise rejection. You still need to handle the rejected promise in your call site — the hook is a side-effect, not a recovery mechanism.
KiteTicker error events
TheKiteTicker WebSocket client surfaces errors through events rather than rejected promises.