1#ifndef _PRIVMXLIB_ENDPOINT_EVENT_EXT_EXCEPTION_HPP_
2#define _PRIVMXLIB_ENDPOINT_EVENT_EXT_EXCEPTION_HPP_
4#include "privmx/endpoint/core/Exception.hpp"
6#define DECLARE_SCOPE_ENDPOINT_EXCEPTION(NAME, MSG, SCOPE, CODE, ...) \
7 class NAME : public privmx::endpoint::core::Exception { \
9 static constexpr unsigned int SCOPE_CODE = (CODE); \
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; \
17 inline void NAME::rethrow() const { \
21#define DECLARE_ENDPOINT_EXCEPTION(BASE_SCOPED, NAME, MSG, CODE, ...) \
22 class NAME : public BASE_SCOPED { \
24 static constexpr unsigned int FULL_CODE = (BASE_SCOPED::SCOPE_CODE << 16) | (CODE); \
25 NAME() : BASE_SCOPED(MSG, #NAME, CODE) {} \
26 NAME(const std::string& new_of_description) : BASE_SCOPED(MSG, #NAME, CODE, new_of_description) {} \
27 void rethrow() const override; \
29 inline void NAME::rethrow() const { \
37#define ENDPOINT_EVENT_EXCEPTION_CODE 0x00090000
39DECLARE_SCOPE_ENDPOINT_EXCEPTION(EndpointEventException,
"Unknown endpoint event exception",
"Event", 0x0009)
41#define EVENT_EXCEPTIONS(X) \
42 X(ForbiddenChannelNameException, "Forbidden channel name", 0x0002) \
43 X(CannotExtractContextCustomEvent, "Cannot extract ContextCustomEvent", 0x0003) \
44 X(InvalidEncryptedEventDataVersionException, "Invalid version of encrypted event data", 0x0005)
46#define PRIVMX_EVENT_DECLARE(NAME, MSG, CODE) DECLARE_ENDPOINT_EXCEPTION(EndpointEventException, NAME, MSG, CODE)
47EVENT_EXCEPTIONS(PRIVMX_EVENT_DECLARE)
48#undef PRIVMX_EVENT_DECLARE
51#define PRIVMX_EVENT_CODE(NAME, MSG, CODE) NAME::FULL_CODE,
53 privmx::endpoint::core::exceptionCodesUnique({EVENT_EXCEPTIONS(PRIVMX_EVENT_CODE)}),
54 "Duplicate exception code in event scope"
56#undef PRIVMX_EVENT_CODE
57#undef EVENT_EXCEPTIONS
63#undef DECLARE_SCOPE_ENDPOINT_EXCEPTION
64#undef DECLARE_ENDPOINT_EXCEPTION