12#ifndef _PRIVMXLIB_ENDPOINT_STREAM_EXT_EXCEPTION_HPP_
13#define _PRIVMXLIB_ENDPOINT_STREAM_EXT_EXCEPTION_HPP_
15#include "privmx/endpoint/core/Exception.hpp"
17#define DECLARE_SCOPE_ENDPOINT_EXCEPTION(NAME, MSG, SCOPE, CODE, ...) \
18 class NAME : public privmx::endpoint::core::Exception { \
20 static constexpr unsigned int SCOPE_CODE = (CODE); \
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; \
28 inline void NAME::rethrow() const { \
32#define DECLARE_ENDPOINT_EXCEPTION(BASE_SCOPED, NAME, MSG, CODE, ...) \
33 class NAME : public BASE_SCOPED { \
35 static constexpr unsigned int FULL_CODE = (BASE_SCOPED::SCOPE_CODE << 16) | (CODE); \
36 NAME() : BASE_SCOPED(MSG, #NAME, CODE) {} \
37 NAME(const std::string& new_of_description) : BASE_SCOPED(MSG, #NAME, CODE, new_of_description) {} \
38 void rethrow() const override; \
40 inline void NAME::rethrow() const { \
48#define ENDPOINT_STREAM_EXCEPTION_CODE 0x00080000
50DECLARE_SCOPE_ENDPOINT_EXCEPTION(EndpointStreamException,
"Unknown endpoint stream exception",
"StreamRoom", 0x0008)
52#define STREAM_EXCEPTIONS(X) \
53 X(UnknowStreamRoomFormatException, "Unknown stream room format", 0x0005) \
54 X(WebRTCException, "WebRTC error", 0x0009) \
55 X(IncorrectStreamHandleException, "Incorrect stream handle", 0x000A) \
56 X(IncorrectTrackIdException, "Incorrect track id", 0x000C) \
57 X(CannotExtractStreamRoomCreatedEventException, "Cannot extract StreamRoomCreatedEvent", 0x000F) \
58 X(CannotExtractStreamRoomUpdatedEventException, "Cannot extract StreamRoomUpdatedEvent", 0x0010) \
59 X(CannotExtractStreamRoomDeletedEventException, "Cannot extract StreamRoomDeletedEvent", 0x0011) \
60 X(CannotExtractStreamPublishedEventException, "Cannot extract StreamPublishedEvent", 0x0012) \
61 X(CannotExtractStreamRoomJoinedEventException, "Cannot extract StreamRoomJoinedEvent", 0x0013) \
62 X(CannotExtractStreamUnpublishedEventException, "Cannot extract StreamUnpublishedEvent", 0x0014) \
63 X(CannotExtractStreamRoomLeftEventException, "Cannot extract StreamRoomLeftEvent", 0x0015) \
64 X(StreamRoomDataIntegrityException, "Failed StreamRoom data integrity check", 0x0018) \
65 X(CannotExtractStreamSubscribedEventException, "Cannot extract StreamSubscribedEvent", 0x001B) \
66 X(CannotExtractStreamUnsubscribedEventException, "Cannot extract StreamUnsubscribedEvent", 0x001C) \
67 X(InvalidTurnServerURIException, "Invalid turn server URI", 0x001D) \
68 X(StreamRoomConnectionNotInitialized, "StreamRoom connection not initialized", 0x0020) \
69 X(StreamHandleNotInitialized, "StreamHandle not initialized", 0x0021) \
70 X(StreamAlreadyPublishedException, "Stream is already published", 0x0022) \
71 X(CannotExtractStreamUpdatedEventException, "Cannot extract StreamUpdatedEvent", 0x0023) \
72 X(NullCallbackException, "Callback must not be null", 0x0024) \
73 X(UnknownTypeException, "Unknown type encountered", 0x0025) \
74 X(ThereCanBeOnlyOneDataTrackException, "There can be only one dataTrack per user in StreamRoom", 0x0026) \
75 X(DataTrackNotInitializedException, "Data track not initialized", 0x0027) \
76 X(NoStreamEncryptionKeyException, "No stream encryption key", 0x0028) \
77 X(NoStreamDecryptionKeyException, "No stream decryption key", 0x0029) \
78 X(InvalidEncryptionKeyIdLengthException, "Invalid encryption key id length", 0x002A) \
79 X(InvalidMessageHeaderLengthException, "Invalid message header length", 0x002B) \
80 X(UnsupportedMessageFormatVersionException, "Unsupported message format version length", 0x002C) \
81 X(AlreadyJoinedStreamRoomException, "StreamRoom already joined", 0x002D) \
82 X(InvalidDataChannelSeqException, "Invalid data channel sequence number", 0x002E) \
83 X(StreamHandleNotPublishedException, "StreamHandle not published", 0x002F) \
84 X(SubscriberStreamAlreadyCreatedException, "Subscriber stream is already created", 0x0030) \
85 X(SubscriberStreamHandleNotInitialized, "SubscriberStreamHandle not initialized", 0x0031)
87#define PRIVMX_STREAM_DECLARE(NAME, MSG, CODE) DECLARE_ENDPOINT_EXCEPTION(EndpointStreamException, NAME, MSG, CODE)
88STREAM_EXCEPTIONS(PRIVMX_STREAM_DECLARE)
89#undef PRIVMX_STREAM_DECLARE
92#define PRIVMX_STREAM_CODE(NAME, MSG, CODE) NAME::FULL_CODE,
94 privmx::endpoint::core::exceptionCodesUnique({STREAM_EXCEPTIONS(PRIVMX_STREAM_CODE)}),
95 "Duplicate exception code in stream scope"
97#undef PRIVMX_STREAM_CODE
98#undef STREAM_EXCEPTIONS
104#undef DECLARE_SCOPE_ENDPOINT_EXCEPTION
105#undef DECLARE_ENDPOINT_EXCEPTION