PrivMX Endpoint v2.7.0
Loading...
Searching...
No Matches
ThreadException.hpp
1#ifndef _PRIVMXLIB_ENDPOINT_THREAD_EXT_EXCEPTION_HPP_
2#define _PRIVMXLIB_ENDPOINT_THREAD_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 thread {
35
36#define ENDPOINT_THREAD_EXCEPTION_CODE 0x00030000
37
38DECLARE_SCOPE_ENDPOINT_EXCEPTION(EndpointThreadException, "Unknown endpoint thread exception", "Thread", 0x0003)
39DECLARE_ENDPOINT_EXCEPTION(EndpointThreadException, NotInitializedException, "Endpoint not initialized", 0x0001)
40DECLARE_ENDPOINT_EXCEPTION(EndpointThreadException, CannotExtractThreadCreatedEventException, "Cannot extract ThreadCreatedEvent", 0x0002)
41DECLARE_ENDPOINT_EXCEPTION(EndpointThreadException, CannotExtractThreadUpdatedEventException, "Cannot extract ThreadUpdatedEvent", 0x0003)
42DECLARE_ENDPOINT_EXCEPTION(EndpointThreadException, CannotExtractThreadNewMessageEventException, "Cannot extract ThreadNewMessageEvent", 0x0004)
43DECLARE_ENDPOINT_EXCEPTION(EndpointThreadException, CannotExtractThreadDeletedEventException, "Cannot extract ThreadDeletedEvent", 0x0005)
44DECLARE_ENDPOINT_EXCEPTION(EndpointThreadException, CannotExtractThreadDeletedMessageEventException, "Cannot extract ThreadDeletedMessageEvent", 0x0006)
45DECLARE_ENDPOINT_EXCEPTION(EndpointThreadException, IncorrectKeyIdFormatException, "Incorrect key id format", 0x0007)
46DECLARE_ENDPOINT_EXCEPTION(EndpointThreadException, CannotExtractThreadStatsEventException, "Cannot extract ThreadStatsEvent", 0x0008)
47DECLARE_ENDPOINT_EXCEPTION(EndpointThreadException, AlreadySubscribedException, "Already subscribed", 0x0009)
48DECLARE_ENDPOINT_EXCEPTION(EndpointThreadException, NotSubscribedException, "Cannot unsubscribe if not subscribed", 0x000A)
49DECLARE_ENDPOINT_EXCEPTION(EndpointThreadException, InvalidEncryptedThreadDataVersionException, "Invalid version of encrypted thread data", 0x000B)
50DECLARE_ENDPOINT_EXCEPTION(EndpointThreadException, InvalidEncryptedMessageDataVersionException, "Invalid version of encrypted message data", 0x000C)
51DECLARE_ENDPOINT_EXCEPTION(EndpointThreadException, UnknowThreadFormatException, "Unknown Thread format", 0x000D)
52DECLARE_ENDPOINT_EXCEPTION(EndpointThreadException, UnknowMessageFormatException, "Unknown Message format", 0x000E)
53DECLARE_ENDPOINT_EXCEPTION(EndpointThreadException, CannotExtractThreadMessageUpdatedEventException, "Cannot extract ThreadMessageUpdatedEvent", 0x000F)
54DECLARE_ENDPOINT_EXCEPTION(EndpointThreadException, ThreadPublicDataMismatchException, "Thread public data mismatch", 0x0010)
55DECLARE_ENDPOINT_EXCEPTION(EndpointThreadException, MessagePublicDataMismatchException, "Message public data mismatch", 0x0011)
56DECLARE_ENDPOINT_EXCEPTION(EndpointThreadException, ThreadDataIntegrityException, "Failed thread data integrity check", 0x0014)
57DECLARE_ENDPOINT_EXCEPTION(EndpointThreadException, MessageDataIntegrityException, "Failed message data integrity check", 0x0015)
58DECLARE_ENDPOINT_EXCEPTION(EndpointThreadException, ThreadEncryptionKeyValidationException, "Failed Thread encryption key validation", 0x0016)
59DECLARE_ENDPOINT_EXCEPTION(EndpointThreadException, NotImplementedException, "Not Implemented", 0x0017)
60DECLARE_ENDPOINT_EXCEPTION(EndpointThreadException, InvalidSubscriptionQueryException, "Invalid subscriptionQuery", 0x0018)
61
62} // thread
63} // endpoint
64} // privmx
65
66#undef DECLARE_SCOPE_ENDPOINT_EXCEPTION
67#undef DECLARE_ENDPOINT_EXCEPTION
68
69#endif // _PRIVMXLIB_ENDPOINT_THREAD_EXT_EXCEPTION_HPP_