LiveKit C++ Client SDK v1.1.0
Real-time audio/video/data SDK for C++
Loading...
Searching...
No Matches
rpc_error.h
1/*
2 * Copyright 2025 LiveKit
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an “AS IS” BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <cstdint>
20#include <stdexcept>
21#include <string>
22
23#include "livekit/visibility.h"
24
25namespace livekit {
26
27namespace proto {
28class RpcError;
29}
30
40class LIVEKIT_API RpcError : public std::runtime_error {
41public:
43 enum class ErrorCode : std::uint32_t {
44 APPLICATION_ERROR = 1500,
45 CONNECTION_TIMEOUT = 1501,
46 RESPONSE_TIMEOUT = 1502,
47 RECIPIENT_DISCONNECTED = 1503,
48 RESPONSE_PAYLOAD_TOO_LARGE = 1504,
49 SEND_FAILED = 1505,
50
51 UNSUPPORTED_METHOD = 1400,
52 RECIPIENT_NOT_FOUND = 1401,
53 REQUEST_PAYLOAD_TOO_LARGE = 1402,
54 UNSUPPORTED_SERVER = 1403,
55 UNSUPPORTED_VERSION = 1404,
56 };
57
64 RpcError(std::uint32_t code, std::string message, std::string data = {});
65
71 RpcError(ErrorCode code, std::string message, std::string data = {});
72
77 std::uint32_t code() const noexcept;
78
80 const std::string& message() const noexcept;
81
84 const std::string& data() const noexcept;
85
91 static RpcError builtIn(ErrorCode code, const std::string& data = {});
92
93protected:
94 // ----- Protected: only used by LocalParticipant (internal SDK code) -----
95 proto::RpcError toProto() const;
96 static RpcError fromProto(const proto::RpcError& err);
97
98 friend class LocalParticipant;
99 friend class FfiClient;
100
101private:
102 static const char* defaultMessageFor(ErrorCode code);
103
104 std::uint32_t code_;
105 std::string message_;
106 std::string data_;
107};
108
109} // namespace livekit
Represents the local participant in a room.
Definition local_participant.h:55
Specialized error type for RPC methods.
Definition rpc_error.h:40
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.
ErrorCode
Built-in error codes.
Definition rpc_error.h:43
std::uint32_t code() const noexcept
Numeric error code.
Public API for the LiveKit C++ Client SDK.
Definition audio_frame.h:25