1#ifndef _PRIVMXLIB_ENDPOINT_STORE_EXT_EXCEPTION_HPP_
2#define _PRIVMXLIB_ENDPOINT_STORE_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 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; \
16 inline void NAME::rethrow() const { \
20#define DECLARE_ENDPOINT_EXCEPTION(BASE_SCOPED, NAME, MSG, CODE, ...) \
21 class NAME : public BASE_SCOPED { \
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; \
27 inline void NAME::rethrow() const { \
35#define ENDPOINT_STORE_EXCEPTION_CODE 0x00040000
37DECLARE_SCOPE_ENDPOINT_EXCEPTION(EndpointStoreException,
"Unknown endpoint store exception",
"Store", 0x0004)
38DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, NotInitializedException,
"Endpoint not initialized", 0x0001)
39DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, CannotExtractStoreCreatedEventException,
"Cannot extract StoreCreatedEvent", 0x0002)
40DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, CannotExtractStoreUpdatedEventException,
"Cannot extract StoreUpdatedEvent", 0x0003)
41DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, CannotExtractStoreStatsChangedEventException,
"Cannot extract StoreStatsChangedEvent", 0x0004)
42DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, CannotExtractStoreFileCreatedEventException,
"Cannot extract StoreFileCreatedEvent", 0x0005)
43DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, CannotExtractStoreFileUpdatedEventException,
"Cannot extract StoreFileUpdatedEvent", 0x0006)
44DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, CannotExtractStoreFileDeletedEventException,
"Cannot extract StoreFileDeletedEvent", 0x0007)
45DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, CannotExtractStoreDeletedEventException,
"Cannot extract StoreDeletedEvent", 0x000D)
47DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, UnsupportedCipherTypeException,
"Unsupported cipher type", 0x0009)
48DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, FileInvalidChecksumException,
"File invalid checksum", 0x000A)
49DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, FileChunkInvalidChecksumException,
"File chunk invalid checksum", 0x000B)
50DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, FileChunkInvalidCipherChecksumException,
"File chunk invalid cipher checksum", 0x000C)
51DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, InvalidFileChunkSizeException,
"Invalid file chunk size", 0x000E)
52DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, InvalidFileReadHandleException,
"Invalid file handle: handle is not FILE_READ_HANDLE", 0x000F)
53DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, InvalidFileWriteHandleException,
"Invalid file handle: handle is not FILE_WRITE_HANDLE", 0x0010)
54DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, InvalidFileHandleException,
"Invalid file handle: handle does not exist", 0x0011)
55DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, IncorrectKeyIdFormatException,
"Incorrect key id format", 0x0012)
56DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, FileVersionMismatchHandleClosedException,
"File version mismatch, handle closed", 0x0013)
57DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, PosOutOfBoundsException,
"Pos out of bounds", 0x0014)
58DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, FileCorruptedException,
"File corrupted", 0x0015)
59DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, NumberToBigForCPUArchitectureException,
"Number is to big for this CPU Architecture", 0x0016)
60DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, AlreadySubscribedException,
"Already subscribed", 0x0017)
61DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, NotSubscribedException,
"Cannot unsubscribe if not subscribed", 0x0018)
62DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, InvalidEncryptedStoreFileMetaVersionException,
"Invalid version of encrypted file meta", 0x0019)
63DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, InvalidEncryptedStoreDataVersionException,
"Invalid version of encrypted store data", 0x001A)
64DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, NotImplementedException,
"Not Implemented", 0x001B)
65DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, UnknowStoreFormatException,
"Unknown Store format", 0x001C)
66DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, UnknowFileFormatException,
"Unknown File format", 0x001D)
67DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, FileFetchFailedException,
"File fetch failed", 0x001E)
68DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, FileVersionMismatchException,
"File version mismatch", 0x001F)
69DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, StorePublicDataMismatchException,
"Store public data mismatch", 0x0020)
70DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, FilePublicDataMismatchException,
"File public data mismatch", 0x0021)
71DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, WritingToFileInteruptedWrittenDataSmallerThenDeclaredException,
"Writing to file interupted. Written data smaller then declared", 0x0022)
72DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, FileDecryptionFailedException,
"FileDecryptionFailed", 0x0023)
73DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, StoreEncryptionKeyValidationException,
"Failed Store encryption key validation", 0x0026)
74DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, StoreDataIntegrityException,
"Failed Store data integrity check", 0x0027)
75DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, FileDataIntegrityException,
"Failed file data integrity check", 0x0028)
77DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, InvalidHashSizeException,
"Invalid hash size", 0x0029)
78DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, HashIndexOutOfBoundsException,
"Hash index out of bounds", 0x0029)
79DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, InvalidFileTopHashException,
"Invalid file top hash", 0x002A)
80DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, FileSyncFailedHandleCloseException,
"File sync failed, handle closed", 0x002B)
81DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, FileRandomWriteInternalException,
"File random write internal Exception ", 0x002C)
83DECLARE_ENDPOINT_EXCEPTION(EndpointStoreException, InvalidSubscriptionQueryException,
"Invalid subscriptionQuery", 0x002D)
90#undef DECLARE_SCOPE_ENDPOINT_EXCEPTION
91#undef DECLARE_ENDPOINT_EXCEPTION