PrivMX Endpoint v2.7.0
Loading...
Searching...
No Matches
InboxException.hpp
1#ifndef _PRIVMXLIB_ENDPOINT_INBOX_EXT_EXCEPTION_HPP_
2#define _PRIVMXLIB_ENDPOINT_INBOX_EXT_EXCEPTION_HPP_
3
4#include "privmx/endpoint/core/Exception.hpp"
5
6#define DECLARE_SCOPE_ENDPOINT_EXCEPTION(NAME, MSG, SCOPE, CODE, ...) \
7 class NAME : public privmx::endpoint::core::Exception { \
8 public: \
9 NAME() : privmx::endpoint::core::Exception(MSG, #NAME, SCOPE, (CODE << 16)) {} \
10 NAME(const std::string& msg, const std::string& name, unsigned int code) \
11 : privmx::endpoint::core::Exception(msg, name, SCOPE, (CODE << 16) | code, std::string()) {} \
12 NAME(const std::string& msg, const std::string& name, unsigned int code, const std::string& description) \
13 : privmx::endpoint::core::Exception(msg, name, SCOPE, (CODE << 16) | code, description) {} \
14 void rethrow() const override; \
15 }; \
16 inline void NAME::rethrow() const { \
17 throw *this; \
18 };
19
20#define DECLARE_ENDPOINT_EXCEPTION(BASE_SCOPED, NAME, MSG, CODE, ...) \
21 class NAME : public BASE_SCOPED { \
22 public: \
23 NAME() : BASE_SCOPED(MSG, #NAME, CODE) {} \
24 NAME(const std::string& new_of_description) : BASE_SCOPED(MSG, #NAME, CODE, new_of_description) {} \
25 void rethrow() const override; \
26 }; \
27 inline void NAME::rethrow() const { \
28 throw *this; \
29 };
30
31namespace privmx {
32namespace endpoint {
33namespace inbox {
34
35#define ENDPOINT_INBOX_EXCEPTION_CODE 0x00070000
36
37DECLARE_SCOPE_ENDPOINT_EXCEPTION(EndpointInboxException, "Unknown endpoint inbox exception", "Inbox", 0x0007)
38DECLARE_ENDPOINT_EXCEPTION(EndpointInboxException, NotInitializedException, "Endpoint not initialized", 0x0001)
39DECLARE_ENDPOINT_EXCEPTION(EndpointInboxException, UnknownInboxHandleException, "Unknown inbox handle Id", 0x0002)
40DECLARE_ENDPOINT_EXCEPTION(EndpointInboxException, InboxHandleIsNotTiedToInboxFileHandleException, "inboxHandle is not tied to inboxFileHandle", 0x0003)
41DECLARE_ENDPOINT_EXCEPTION(EndpointInboxException, CannotExtractInboxCreatedEventException, "Cannot extract InboxCreatedEvent", 0x0004)
42DECLARE_ENDPOINT_EXCEPTION(EndpointInboxException, CannotExtractInboxUpdatedEventException, "Cannot extract InboxUpdatedEvent", 0x0005)
43DECLARE_ENDPOINT_EXCEPTION(EndpointInboxException, CannotExtractInboxDeletedEventException, "Cannot extract InboxDeletedEvent", 0x0006)
44DECLARE_ENDPOINT_EXCEPTION(EndpointInboxException, IncorrectKeyIdFormatException, "Incorrect key id format", 0x0007)
45DECLARE_ENDPOINT_EXCEPTION(EndpointInboxException, FailedToDecryptFileMetaException, "Failed to decrypt file meta", 0x0008)
46DECLARE_ENDPOINT_EXCEPTION(EndpointInboxException, FailedToExtractMessagePublicMetaException, "Failed to extract message public meta", 0x0009)
47DECLARE_ENDPOINT_EXCEPTION(EndpointInboxException, FileVersionMismatchHandleClosedException, "File version mismatch, handle closed", 0x000A)
48DECLARE_ENDPOINT_EXCEPTION(EndpointInboxException, PosOutOfBoundsException, "Pos out of bounds", 0x000B)
49DECLARE_ENDPOINT_EXCEPTION(EndpointInboxException, NumberToBigForCPUArchitectureException, "ChunkSize bigger then size_t", 0x000C)
50DECLARE_ENDPOINT_EXCEPTION(EndpointInboxException, AlreadySubscribedException, "Already subscribed", 0x000D)
51DECLARE_ENDPOINT_EXCEPTION(EndpointInboxException, NotSubscribedException, "Cannot unsubscribe if not subscribed", 0x000E)
52DECLARE_ENDPOINT_EXCEPTION(EndpointInboxException, InvalidEncryptedInboxDataVersionException, "Invalid version of encrypted Inbox data", 0x000F)
53DECLARE_ENDPOINT_EXCEPTION(EndpointInboxException, CannotExtractInboxEntryCreatedEventException, "Cannot extract InboxEntryCreatedEvent", 0x0010)
54DECLARE_ENDPOINT_EXCEPTION(EndpointInboxException, CannotExtractInboxEntryDeletedException, "Cannot extract InboxEntryDeleted", 0x0011)
55DECLARE_ENDPOINT_EXCEPTION(EndpointInboxException, FileFetchFailedException, "File fetch failed", 0x0012)
56DECLARE_ENDPOINT_EXCEPTION(EndpointInboxException, InboxPublicDataMismatchException, "Inbox public data mismatch", 0x0013)
57DECLARE_ENDPOINT_EXCEPTION(EndpointInboxException, WritingToEntryInteruptedWrittenDataSmallerThenDeclaredException, "Writing to entry interupted. Written data smaller then declared", 0x0014)
58DECLARE_ENDPOINT_EXCEPTION(EndpointInboxException, HandleIsUsedInInboxHandleException, "Handle is used in inbox handle", 0x0015)
59DECLARE_ENDPOINT_EXCEPTION(EndpointInboxException, InvalidFileReadHandleException, "Invalid file handle: handle is not FILE_READ_HANDLE", 0x0016)
60DECLARE_ENDPOINT_EXCEPTION(EndpointInboxException, InvalidFileWriteHandleException, "Invalid file handle: handle is not FILE_WRITE_HANDLE", 0x0017)
61DECLARE_ENDPOINT_EXCEPTION(EndpointInboxException, UnknownInboxFormatException, "Unknown Inbox format", 0x0020)
62DECLARE_ENDPOINT_EXCEPTION(EndpointInboxException, InboxDataIntegrityException, "Failed inbox data integrity check", 0x0021)
63DECLARE_ENDPOINT_EXCEPTION(EndpointInboxException, InboxEncryptionKeyValidationException, "Failed inbox encryption key validation", 0x0022)
64DECLARE_ENDPOINT_EXCEPTION(EndpointInboxException, NotImplementedException, "Not Implemented", 0x0023)
65DECLARE_ENDPOINT_EXCEPTION(EndpointInboxException, InvalidSubscriptionQueryException, "Invalid subscriptionQuery", 0x0024)
66
67DECLARE_ENDPOINT_EXCEPTION(EndpointInboxException, InboxModuleDoesNotSupportQueriesYetException, "Inbox module does not support queries yet.", 0x0099)
68
69
70} // store
71} // endpoint
72} // privmx
73
74#undef DECLARE_SCOPE_ENDPOINT_EXCEPTION
75#undef DECLARE_ENDPOINT_EXCEPTION
76
77#endif // _PRIVMXLIB_ENDPOINT_INBOX_EXT_EXCEPTION_HPP_