Error

data class Error<T>(val errorCode: Int, val errorMessage: String, val errorData: T? = null) : CallData<T>

Error response. errorCode discriminates the error type — typically a @KsError-bound user code, with sentinels com.monkopedia.ksrpc.KsrpcException.ENDPOINT_NOT_FOUND_CODE and com.monkopedia.ksrpc.KsrpcException.INTERNAL_ERROR_CODE for the built-in cases. errorMessage is human-readable. errorData is the optional typed payload encoded in the wire format's native type Tnull when no @KsError binding matched. readSerialized returns errorData (it is the same wire-format T as a Serialized payload — naturally reusable by transports / serializers).

Constructors

Link copied to clipboard
constructor(errorCode: Int, errorMessage: String, errorData: T? = null)

Properties

Link copied to clipboard
open override val errorCode: Int

Code for Error variants; null otherwise. Lets transports populate native error fields without pattern-matching on the variant.

Link copied to clipboard
val errorData: T?
Link copied to clipboard
open override val errorMessage: String

Human-readable message for Error variants; null otherwise.

Link copied to clipboard
open override val isBinary: Boolean = false
Link copied to clipboard
open override val isError: Boolean = true

Convenience: true iff this is an Error variant.

Functions

Link copied to clipboard
open override fun readBinary(): RpcBinaryData

Get the RpcBinaryData for the binary data held by this call. If this is not binary data then throws IllegalStateException.

Link copied to clipboard
open override fun readSerialized(): T

Read the serialized content of this object. If this is binary data then throws IllegalStateException.

Link copied to clipboard
open override fun toString(): String