1#ifndef _PRIVMXLIB_ENDPOINT_KVDB_EXT_EXCEPTION_HPP_
2#define _PRIVMXLIB_ENDPOINT_KVDB_EXT_EXCEPTION_HPP_
5#include "privmx/endpoint/core/Exception.hpp"
7#define DECLARE_SCOPE_ENDPOINT_EXCEPTION(NAME, MSG, SCOPE, CODE, ...) \
8 class NAME : public privmx::endpoint::core::Exception { \
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 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; \
28 inline void NAME::rethrow() const { \
36#define ENDPOINT_KVDB_EXCEPTION_CODE 0x00090000
38DECLARE_SCOPE_ENDPOINT_EXCEPTION(EndpointKvdbException,
"Unknown endpoint kvdb exception",
"Kvdb", 0x0009)
39DECLARE_ENDPOINT_EXCEPTION(EndpointKvdbException, NotInitializedException,
"Endpoint not initialized", 0x0001)
40DECLARE_ENDPOINT_EXCEPTION(EndpointKvdbException, CannotExtractKvdbCreatedEventException,
"Cannot extract KvdbCreatedEvent", 0x0002)
41DECLARE_ENDPOINT_EXCEPTION(EndpointKvdbException, CannotExtractKvdbUpdatedEventException,
"Cannot extract KvdbUpdatedEvent", 0x0003)
42DECLARE_ENDPOINT_EXCEPTION(EndpointKvdbException, CannotExtractKvdbDeletedEventException,
"Cannot extract KvdbDeletedEvent", 0x0004)
43DECLARE_ENDPOINT_EXCEPTION(EndpointKvdbException, CannotExtractKvdbStatsEventException,
"Cannot extract KvdbStatsEvent", 0x0005)
44DECLARE_ENDPOINT_EXCEPTION(EndpointKvdbException, CannotExtractKvdbNewEntryEventException,
"Cannot extract KvdbNewEntryEvent", 0x0006)
45DECLARE_ENDPOINT_EXCEPTION(EndpointKvdbException, CannotExtractKvdbEntryUpdatedEventException,
"Cannot extract KvdbKvdbEntryUpdatedEvent", 0x0006)
46DECLARE_ENDPOINT_EXCEPTION(EndpointKvdbException, CannotExtractKvdbDeletedEntryEventException,
"Cannot extract KvdbDeletedEntryEvent", 0x0007)
47DECLARE_ENDPOINT_EXCEPTION(EndpointKvdbException, KvdbPublicDataMismatchException,
"Kvdb public data mismatch", 0x0008)
48DECLARE_ENDPOINT_EXCEPTION(EndpointKvdbException, InvalidEncryptedKvdbDataVersionException,
"Invalid version of encrypted kvdb data", 0x0009)
49DECLARE_ENDPOINT_EXCEPTION(EndpointKvdbException, KvdbEntryPublicDataMismatchException,
"Kvdb entry public data mismatch", 0x000A)
50DECLARE_ENDPOINT_EXCEPTION(EndpointKvdbException, InvalidEncryptedKvdbEntryDataVersionException,
"Invalid version of encrypted kvdb entry data", 0x000B)
51DECLARE_ENDPOINT_EXCEPTION(EndpointKvdbException, KvdbEncryptionKeyValidationException,
"Failed kvdb encryption key validation", 0x000C)
52DECLARE_ENDPOINT_EXCEPTION(EndpointKvdbException, AlreadySubscribedException,
"Already subscribed", 0x000D)
53DECLARE_ENDPOINT_EXCEPTION(EndpointKvdbException, NotSubscribedException,
"Cannot unsubscribe if not subscribed", 0x000E)
54DECLARE_ENDPOINT_EXCEPTION(EndpointKvdbException, UnknownKvdbFormatException,
"Unknown kvdb format", 0x000F)
55DECLARE_ENDPOINT_EXCEPTION(EndpointKvdbException, UnknownKvdbEntryFormatException,
"Unknown item format", 0x0010)
56DECLARE_ENDPOINT_EXCEPTION(EndpointKvdbException, KvdbDataIntegrityException,
"Failed kvdb data integrity check", 0x0011)
57DECLARE_ENDPOINT_EXCEPTION(EndpointKvdbException, KvdbEntryDataIntegrityException,
"Failed kvdb entry data integrity check", 0x0012)
58DECLARE_ENDPOINT_EXCEPTION(EndpointKvdbException, NotImplementedException,
"Not Implemented", 0x00013)
59DECLARE_ENDPOINT_EXCEPTION(EndpointKvdbException, InvalidSubscriptionQueryException,
"Invalid subscriptionQuery", 0x00014)
65#undef DECLARE_SCOPE_ENDPOINT_EXCEPTION
66#undef DECLARE_ENDPOINT_EXCEPTION