PrivMX Endpoint v2.7.0
Loading...
Searching...
No Matches
StreamException.hpp
1/*
2PrivMX Endpoint.
3Copyright © 2024 Simplito sp. z o.o.
4
5This file is part of the PrivMX Platform (https://privmx.dev).
6This software is Licensed under the PrivMX Free License.
7
8See the License for the specific language governing permissions and
9limitations under the License.
10*/
11
12#ifndef _PRIVMXLIB_ENDPOINT_STREAM_EXT_EXCEPTION_HPP_
13#define _PRIVMXLIB_ENDPOINT_STREAM_EXT_EXCEPTION_HPP_
14
15
16#include "privmx/endpoint/core/Exception.hpp"
17
18#define DECLARE_SCOPE_ENDPOINT_EXCEPTION(NAME, MSG, SCOPE, CODE, ...) \
19 class NAME : public privmx::endpoint::core::Exception { \
20 public: \
21 NAME() : privmx::endpoint::core::Exception(MSG, #NAME, SCOPE, (CODE << 16)) {} \
22 NAME(const std::string& msg, const std::string& name, unsigned int code) \
23 : privmx::endpoint::core::Exception(msg, name, SCOPE, (CODE << 16) | code, std::string()) {} \
24 NAME(const std::string& msg, const std::string& name, unsigned int code, const std::string& description) \
25 : privmx::endpoint::core::Exception(msg, name, SCOPE, (CODE << 16) | code, description) {} \
26 void rethrow() const override; \
27 }; \
28 inline void NAME::rethrow() const { \
29 throw *this; \
30 };
31
32#define DECLARE_ENDPOINT_EXCEPTION(BASE_SCOPED, NAME, MSG, CODE, ...) \
33 class NAME : public BASE_SCOPED { \
34 public: \
35 NAME() : BASE_SCOPED(MSG, #NAME, CODE) {} \
36 NAME(const std::string& new_of_description) : BASE_SCOPED(MSG, #NAME, CODE, new_of_description) {} \
37 void rethrow() const override; \
38 }; \
39 inline void NAME::rethrow() const { \
40 throw *this; \
41 };
42
43namespace privmx {
44namespace endpoint {
45namespace stream {
46
47#define ENDPOINT_STREAM_EXCEPTION_CODE 0x00080000
48
49DECLARE_SCOPE_ENDPOINT_EXCEPTION(EndpointStreamException, "Unknown endpoint stream exception", "StreamRoom", 0x0008)
50DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, NotInitializedException, "Endpoint not initialized", 0x0001)
51DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, NotImplementedException, "Not Implemented", 0x0002)
52DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, InvalidEncryptedStreamRoomDataVersionException, "Invalid version of encrypted stream room data", 0x0003)
53DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, StreamRoomPublicDataMismatchException, "Stream room public data mismatch", 0x0004)
54DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, UnknowStreamRoomFormatException, "Unknown stream room format", 0x0005)
55DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, InvalidStreamWebSocketRequestIdException, "Invalid stream web socket request id", 0x0006)
56DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, StreamWebsocketDisconnectedException, "Stream websocket disconnected", 0x0007)
57DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, NetConnectionException, "Network connection error", 0x0008);
58DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, WebRTCException, "WebRTC error", 0x0009);
59DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, IncorrectStreamHandleException, "Incorrect stream handle", 0x000A);
60DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, StreamCacheException, "Incorrect Stream Cache state", 0x000B);
61DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, IncorrectTrackIdException, "Incorrect track id", 0x000C);
62DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, AlreadySubscribedException, "Already subscribed", 0x000D)
63DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, NotSubscribedException, "Cannot unsubscribe if not subscribed", 0x000E)
64DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, CannotExtractStreamRoomCreatedEventException, "Cannot extract StreamRoomCreatedEvent", 0x000F)
65DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, CannotExtractStreamRoomUpdatedEventException, "Cannot extract StreamRoomUpdatedEvent", 0x0010)
66DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, CannotExtractStreamRoomDeletedEventException, "Cannot extract StreamRoomDeletedEvent", 0x0011)
67DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, CannotExtractStreamPublishedEventException, "Cannot extract StreamPublishedEvent", 0x0012)
68DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, CannotExtractStreamJoinedEventException, "Cannot extract StreamJoinedEvent", 0x0013)
69DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, CannotExtractStreamUnpublishedEventException, "Cannot extract StreamUnpublishedEvent", 0x0014)
70DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, CannotExtractStreamLeftEventException, "Cannot extract StreamLeftEvent", 0x0015)
71DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, StreamRoomEncryptionKeyValidationException, "Failed StreamRoom encryption key validation", 0x0016);
72DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, UnknownStreamRoomFormatException, "Unknown StreamRoom format", 0x0017);
73DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, StreamRoomDataIntegrityException, "Failed StreamRoom data integrity check", 0x0018);
74DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, InvalidSubscriptionQueryException, "Invalid subscriptionQuery", 0x0019);
75DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, CannotExtractStreamNewStreamsEventException, "Cannot extract StreamNewStreamsEvent", 0x001A)
76DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, CannotExtractStreamsUpdatedEventException, "Cannot extract StreamsUpdatedEvent", 0x001B)
77DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, CannotGetRoomOnStreamsUpdateEventException, "Cannot get room on streamsUpdateEvent", 0x001C)
78DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, InvalidTurnServerURIException, "Invalid turn server URI", 0x001D)
79DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, PeerConnectionAlreadyInitializedException, "Peer Connection already initialized", 0x001E)
80DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, PeerConnectionNotInitializedException, "Peer Connection not initialized", 0x001F)
81
82DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, StreamRoomConnectionNotInitialized, "StreamRoom connection not initialized", 0x0020)
83DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, StreamHandleNotInitialized, "StreamHandle not initialized", 0x0021)
84DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, StreamIsPublished, "Stream is published", 0x0022)
85DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, CannotExtractStreamUpdatedEventException, "Cannot extract StreamUpdatedEvent", 0x0023)
86DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, NullCallbackException, "Callback must not be null", 0x0024)
87DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, UnknownTypeException, "Unknown type encountered", 0x0025)
88} // stream
89} // endpoint
90} // privmx
91
92#undef DECLARE_SCOPE_ENDPOINT_EXCEPTION
93#undef DECLARE_ENDPOINT_EXCEPTION
94
95#endif // _PRIVMXLIB_ENDPOINT_STREAM_EXT_EXCEPTION_HPP_