1#ifndef _PRIVMXLIB_ENDPOINT_THREAD_EXT_EXCEPTION_HPP_
2#define _PRIVMXLIB_ENDPOINT_THREAD_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_THREAD_EXCEPTION_CODE 0x00030000
39DECLARE_SCOPE_ENDPOINT_EXCEPTION(EndpointThreadException,
"Unknown endpoint thread exception",
"Thread", 0x0003)
41#define THREAD_EXCEPTIONS(X) \
42 X(CannotExtractThreadCreatedEventException, "Cannot extract ThreadCreatedEvent", 0x0002) \
43 X(CannotExtractThreadUpdatedEventException, "Cannot extract ThreadUpdatedEvent", 0x0003) \
44 X(CannotExtractThreadNewMessageEventException, "Cannot extract ThreadNewMessageEvent", 0x0004) \
45 X(CannotExtractThreadDeletedEventException, "Cannot extract ThreadDeletedEvent", 0x0005) \
46 X(CannotExtractThreadDeletedMessageEventException, "Cannot extract ThreadDeletedMessageEvent", 0x0006) \
47 X(CannotExtractThreadStatsEventException, "Cannot extract ThreadStatsEvent", 0x0008) \
48 X(InvalidEncryptedMessageDataVersionException, "Invalid version of encrypted message data", 0x000C) \
49 X(UnknowThreadFormatException, "Unknown Thread format", 0x000D) \
50 X(UnknowMessageFormatException, "Unknown Message format", 0x000E) \
51 X(CannotExtractThreadMessageUpdatedEventException, "Cannot extract ThreadMessageUpdatedEvent", 0x000F) \
52 X(MessagePublicDataMismatchException, "Message public data mismatch", 0x0011) \
53 X(ThreadDataIntegrityException, "Failed thread data integrity check", 0x0014) \
54 X(MessageDataIntegrityException, "Failed message data integrity check", 0x0015)
56#define PRIVMX_THREAD_DECLARE(NAME, MSG, CODE) DECLARE_ENDPOINT_EXCEPTION(EndpointThreadException, NAME, MSG, CODE)
57THREAD_EXCEPTIONS(PRIVMX_THREAD_DECLARE)
58#undef PRIVMX_THREAD_DECLARE
61#define PRIVMX_THREAD_CODE(NAME, MSG, CODE) NAME::FULL_CODE,
63 privmx::endpoint::core::exceptionCodesUnique({THREAD_EXCEPTIONS(PRIVMX_THREAD_CODE)}),
64 "Duplicate exception code in thread scope"
66#undef PRIVMX_THREAD_CODE
67#undef THREAD_EXCEPTIONS
74#undef DECLARE_SCOPE_ENDPOINT_EXCEPTION
75#undef DECLARE_ENDPOINT_EXCEPTION