PrivMX Endpoint v2.7.0
Loading...
Searching...
No Matches
EventException.hpp
1#ifndef _PRIVMXLIB_ENDPOINT_EVENT_EXT_EXCEPTION_HPP_
2#define _PRIVMXLIB_ENDPOINT_EVENT_EXT_EXCEPTION_HPP_
3
4
5#include "privmx/endpoint/core/Exception.hpp"
6
7#define DECLARE_SCOPE_ENDPOINT_EXCEPTION(NAME, MSG, SCOPE, CODE, ...) \
8 class NAME : public privmx::endpoint::core::Exception { \
9 public: \
10 NAME() : privmx::endpoint::core::Exception(MSG, #NAME, SCOPE, (CODE << 16)) {} \
11 NAME(const std::string& msg, const std::string& name, unsigned int code) \
12 : privmx::endpoint::core::Exception(msg, name, SCOPE, (CODE << 16) | code, std::string()) {} \
13 NAME(const std::string& msg, const std::string& name, unsigned int code, const std::string& description) \
14 : privmx::endpoint::core::Exception(msg, name, SCOPE, (CODE << 16) | code, description) {} \
15 void rethrow() const override; \
16 }; \
17 inline void NAME::rethrow() const { \
18 throw *this; \
19 };
20
21#define DECLARE_ENDPOINT_EXCEPTION(BASE_SCOPED, NAME, MSG, CODE, ...) \
22 class NAME : public BASE_SCOPED { \
23 public: \
24 NAME() : BASE_SCOPED(MSG, #NAME, CODE) {} \
25 NAME(const std::string& new_of_description) : BASE_SCOPED(MSG, #NAME, CODE, new_of_description) {} \
26 void rethrow() const override; \
27 }; \
28 inline void NAME::rethrow() const { \
29 throw *this; \
30 };
31
32namespace privmx {
33namespace endpoint {
34namespace event {
35
36#define ENDPOINT_EVENT_EXCEPTION_CODE 0x00090000
37
38DECLARE_SCOPE_ENDPOINT_EXCEPTION(EndpointEventException, "Unknown endpoint event exception", "Event", 0x0009)
39DECLARE_ENDPOINT_EXCEPTION(EndpointEventException, NotInitializedException, "Endpoint not initialized", 0x0001)
40DECLARE_ENDPOINT_EXCEPTION(EndpointEventException, ForbiddenChannelNameException, "Forbidden channel name", 0x0002)
41DECLARE_ENDPOINT_EXCEPTION(EndpointEventException, CannotExtractContextCustomEvent, "Cannot extract ContextCustomEvent", 0x0003)
42DECLARE_ENDPOINT_EXCEPTION(EndpointEventException, NotSubscribedException, "Not subscribed", 0x0004)
43DECLARE_ENDPOINT_EXCEPTION(EndpointEventException, AlreadySubscribedException, "Already subscribed", 0x0005)
44DECLARE_ENDPOINT_EXCEPTION(EndpointEventException, InvalidEncryptedEventDataVersionException, "Invalid version of encrypted event data", 0x0005)
45DECLARE_ENDPOINT_EXCEPTION(EndpointEventException, InvalidSubscriptionQueryException, "Invalid subscriptionQuery", 0x0006)
46
47} // event
48} // endpoint
49} // privmx
50
51#undef DECLARE_SCOPE_ENDPOINT_EXCEPTION
52#undef DECLARE_ENDPOINT_EXCEPTION
53
54#endif // _PRIVMXLIB_ENDPOINT_THREAD_EXT_EXCEPTION_HPP_