Android · cartesian-core
Errors
CartesianException and how to handle each case.
Every failure thrown by the SDK is a CartesianException:
| Type | When | What to do |
|---|---|---|
Network | No connectivity, DNS, TLS or timeout | Retry later. The session is kept. |
Http(status) | A non-2xx response other than 401 | Show a generic error. Check your backend logs. |
Unauthorized | 401: the token is invalid or expired | Get a fresh token from your backend and call signIn again |
NotSignedIn | A call that needs a session was made while signed out | Sign in first |
NotConnected | The socket isn't open yet | Wait for connection == Open, or retry |
Command(action) | The backend rejected a socket command | Show the message |
Busy | send was called while an answer is streaming | Call stop() first, or wait |
try {
client.chat.send(text)
} catch (e: CartesianException.Busy) {
client.chat.stop()
} catch (e: CartesianException) {
showError(e.message)
}kotlinThe UI kit handles all of these for you: offline banners, retry and the "That answer didn't finish" card.