encodeError

Server-side: convert a thrown exception into a CallData.Error using this method's reverseErrorMap. The thrown class IS the wire payload's class — when the throwable's runtime class is assignable to a @KsError-bound type, the bound code + serializer are used and the throwable itself is encoded into the wire format S for inclusion in the error frame. There is no KsrpcException wrapper involved on the server side; users throw MyTypedError(...) directly.

The @KsError(code, ...) binding's code is the single source of truth for the wire code — there is no per-throw override mechanism. Callers that want a different code for the same data should bind it differently. Falls back to sentinel-coded built-in errors: RpcEndpointException ->KsrpcException.ENDPOINT_NOT_FOUND_CODE, a thrown KsrpcException without a binding -> its own KsrpcException.code, any other Throwable ->KsrpcException.INTERNAL_ERROR_CODE.