Skip to main content
Every Lokutor error carries a code and a retryable flag (Error Catalog). Three rules cover almost every case:

REST

JavaScript SDK

The SDK raises LokutorError, whose retryable is set from the code. Register a handler with on('error', …) or pass onError to the constructor; it is not a property to assign afterwards.
TTSClient.synthesize() rejects with a LokutorError instead, so wrap it in try/catch:

WebSockets

  • A 402 refuses the handshake before the socket opens. A browser WebSocket only sees close code 1006, so if a connection fails at once, check the balance.
  • On /ws/agent, 429 refuses the handshake. On /ws/tts, the socket opens, sends an auth.rate_limited error frame and closes.
  • Close code 1008 with reason account balance exhausted means a call ran the balance out: show the top-up prompt.
  • Error frames on /ws/agent and /ws/stt can carry a plain string in data instead of the structured object. Treat a string as internal.error, retryable.