LiveKit C++ SDK
Real-time audio/video 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
23namespace livekit {
24
25namespace proto {
26class RpcError;
27}
28
40class RpcError : public std::runtime_error {
41public:
45 enum class ErrorCode : std::uint32_t {
46 APPLICATION_ERROR = 1500,
47 CONNECTION_TIMEOUT = 1501,
48 RESPONSE_TIMEOUT = 1502,
49 RECIPIENT_DISCONNECTED = 1503,
50 RESPONSE_PAYLOAD_TOO_LARGE = 1504,
51 SEND_FAILED = 1505,
52
53 UNSUPPORTED_METHOD = 1400,
54 RECIPIENT_NOT_FOUND = 1401,
55 REQUEST_PAYLOAD_TOO_LARGE = 1402,
56 UNSUPPORTED_SERVER = 1403,
57 UNSUPPORTED_VERSION = 1404,
58 };
59
68 RpcError(std::uint32_t code, std::string message, std::string data = {});
69
77 RpcError(ErrorCode code, std::string message, std::string data = {});
78
85 std::uint32_t code() const noexcept;
86
90 const std::string &message() const noexcept;
91
96 const std::string &data() const noexcept;
97
105 static RpcError builtIn(ErrorCode code, const std::string &data = {});
106
107protected:
108 // ----- Protected: only used by LocalParticipant (internal SDK code) -----
109 proto::RpcError toProto() const;
110 static RpcError fromProto(const proto::RpcError &err);
111
112 friend class LocalParticipant;
113 friend class FfiClient;
114
115private:
116 static const char *defaultMessageFor(ErrorCode code);
117
118 std::uint32_t code_;
119 std::string message_;
120 std::string data_;
121};
122
123} // namespace livekit
Definition local_participant.h:54
Definition rpc_error.h:40
RpcError(std::uint32_t code, std::string message, std::string data={})
static RpcError builtIn(ErrorCode code, const std::string &data={})
const std::string & data() const noexcept
RpcError(ErrorCode code, std::string message, std::string data={})
ErrorCode
Definition rpc_error.h:45
const std::string & message() const noexcept
std::uint32_t code() const noexcept