The Kotlin SDK raises exceptions that all extend the sealed base class SurrealException. Because the hierarchy is sealed, you can branch over it exhaustively with when. See Error handling for usage patterns and the Result variants that avoid exceptions altogether.
Source: surrealdb.kotlin
SurrealException
The sealed base class of all SDK exceptions. Extends RuntimeException.
SurrealTransportException
Raised when the underlying connection fails, drops, or cannot be established.
SurrealProtocolException
Raised when a malformed or unexpected message is received from the server.
SurrealRpcException
Raised when the server returns an RPC error.
| Property | Type | Description |
|---|---|---|
code | Int? | The RPC error code. |
data | JsonElement? | Additional error data from the server. |
SurrealAuthenticationException
A subclass of SurrealRpcException raised when authentication fails (for example, invalid credentials or an expired token).
SurrealFeatureNotSupportedException
Raised when a feature is invoked that the current transport does not support — for example a live query or transaction over HTTP. Extends the base SurrealException. Guard against it with .supports().