Cartesiandocs

Android · cartesian-core

Errors

CartesianException and how to handle each case.

Every failure thrown by the SDK is a CartesianException:

TypeWhenWhat to do
NetworkNo connectivity, DNS, TLS or timeoutRetry later. The session is kept.
Http(status)A non-2xx response other than 401Show a generic error. Check your backend logs.
Unauthorized401: the token is invalid or expiredGet a fresh token from your backend and call signIn again
NotSignedInA call that needs a session was made while signed outSign in first
NotConnectedThe socket isn't open yetWait for connection == Open, or retry
Command(action)The backend rejected a socket commandShow the message
Busysend was called while an answer is streamingCall stop() first, or wait
try {
    client.chat.send(text)
} catch (e: CartesianException.Busy) {
    client.chat.stop()
} catch (e: CartesianException) {
    showError(e.message)
}
kotlin

The UI kit handles all of these for you: offline banners, retry and the "That answer didn't finish" card.