LiveKit C++ Client SDK v1.1.0
Real-time audio/video/data SDK for C++
Loading...
Searching...
No Matches
livekit::RpcError Class Reference

Specialized error type for RPC methods. More...

#include <rpc_error.h>

Inheritance diagram for livekit::RpcError:
Collaboration diagram for livekit::RpcError:

Public Types

enum class  ErrorCode : std::uint32_t {
  APPLICATION_ERROR = 1500 , CONNECTION_TIMEOUT = 1501 , RESPONSE_TIMEOUT = 1502 , RECIPIENT_DISCONNECTED = 1503 ,
  RESPONSE_PAYLOAD_TOO_LARGE = 1504 , SEND_FAILED = 1505 , UNSUPPORTED_METHOD = 1400 , RECIPIENT_NOT_FOUND = 1401 ,
  REQUEST_PAYLOAD_TOO_LARGE = 1402 , UNSUPPORTED_SERVER = 1403 , UNSUPPORTED_VERSION = 1404
}
 Built-in error codes.
 

Public Member Functions

 RpcError (std::uint32_t code, std::string message, std::string data={})
 Construct an RpcError with an explicit numeric code.
 
 RpcError (ErrorCode code, std::string message, std::string data={})
 Construct an RpcError from a built-in ErrorCode.
 
std::uint32_t code () const noexcept
 Numeric error code.
 
const std::string & message () const noexcept
 Human-readable error message.
 
const std::string & data () const noexcept
 Optional extra data associated with the error (JSON recommended).
 

Static Public Member Functions

static RpcError builtIn (ErrorCode code, const std::string &data={})
 Create a built-in RpcError using a predefined ErrorCode and default message text.
 

Protected Member Functions

proto::RpcError toProto () const
 

Static Protected Member Functions

static RpcError fromProto (const proto::RpcError &err)
 

Friends

class LocalParticipant
 
class FfiClient
 

Detailed Description

Specialized error type for RPC methods.

Instances of this type, when thrown in a method handler, will have their code, message, and optional data serialized into a proto::RpcError and sent across the wire. The caller will receive an equivalent error on the other side.

Built-in errors are included (codes 1400–1999) but developers may use arbitrary codes as well.

Constructor & Destructor Documentation

◆ RpcError() [1/2]

livekit::RpcError::RpcError ( std::uint32_t  code,
std::string  message,
std::string  data = {} 
)

Construct an RpcError with an explicit numeric code.

Parameters
codeError code value. Codes 1001–1999 are reserved for built-in errors (see ErrorCode).
messageHuman-readable error message.
dataOptional extra data, e.g. JSON. Empty string means no data.

◆ RpcError() [2/2]

livekit::RpcError::RpcError ( ErrorCode  code,
std::string  message,
std::string  data = {} 
)

Construct an RpcError from a built-in ErrorCode.

Parameters
codeBuilt-in error code.
messageHuman-readable error message.
dataOptional extra data, e.g. JSON. Empty string means no data.

Member Function Documentation

◆ builtIn()

static RpcError livekit::RpcError::builtIn ( ErrorCode  code,
const std::string &  data = {} 
)
static

Create a built-in RpcError using a predefined ErrorCode and default message text.

Parameters
codeBuilt-in error code.
dataOptional extra data payload (JSON recommended).

◆ code()

std::uint32_t livekit::RpcError::code ( ) const
noexcept

Numeric error code.

Codes 1001–1999 are reserved for built-in errors. For built-ins, this value matches the underlying ErrorCode enum value.

◆ data()

const std::string & livekit::RpcError::data ( ) const
noexcept

Optional extra data associated with the error (JSON recommended).

May be an empty string if no data was provided.


The documentation for this class was generated from the following file: