1#ifndef _PRIVMXLIB_ENDPOINT_CORE_EXT_EXCEPTION_HPP_
2#define _PRIVMXLIB_ENDPOINT_CORE_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& description) \
11 : privmx::endpoint::core::Exception(MSG, #NAME, SCOPE, (CODE << 16), description) {} \
12 NAME(const std::string& msg, const std::string& name, unsigned int code) \
13 : privmx::endpoint::core::Exception(msg, name, SCOPE, (CODE << 16) | code, std::string()) {} \
14 NAME(const std::string& msg, const std::string& name, unsigned int code, const std::string& description) \
15 : privmx::endpoint::core::Exception(msg, name, SCOPE, (CODE << 16) | code, description) {} \
16 void rethrow() const override; \
18 inline void NAME::rethrow() const { \
22#define DECLARE_ENDPOINT_EXCEPTION(BASE_SCOPED, NAME, MSG, CODE, ...) \
23 class NAME : public BASE_SCOPED { \
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_CORE_EXCEPTION_CODE 0x00010000
38#define ENDPOINT_CORE_API_EXCEPTION_CODE 0x00020000
40DECLARE_SCOPE_ENDPOINT_EXCEPTION(EndpointCoreException,
"Unknown endpoint core exception",
"Core", 0x0001)
41DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, NoUserEntryForGivenKeyIdException,
"No user entry for given key id", 0x0001)
42DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, InvalidParamsException,
"Invalid params", 0x0002)
43DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, InvalidNumberOfParamsException,
"Invalid number of params", 0x0003)
44DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, UnsupportedTypeException,
"Unsupported type", 0x0004)
45DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, NoHandleFoundException,
"No handle found", 0x0005)
46DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, InvalidDataSignatureException,
"Invalid data signature", 0x0007)
47DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, UnsupportedSerializerBinaryFormatException,
"Unsupported serializer binary format option", 0x0009)
48DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, NotImplementedException,
"Not Implemented", 0x000A)
49DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, InvalidMethodException,
"Invalid method", 0x000B)
50DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, InvalidArgumentTypeException,
"Invalid argument type", 0x000C)
51DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, InvalidBackendRequestModeException,
"Invalid BackendRequest mode", 0x000D)
52DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, UserVerificationFailureException,
"User verification failure", 0x000E)
53DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, UserVerificationMethodUnhandledException,
"UserVerifierInterface.verify() thrown an exception. Implementation of the UserVerifierInterface should provide adequate error handling.", 0x000F)
54DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, MalformedEncryptionKeyException,
"Malformed encryption key", 0x0010)
55DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, UnknownEncryptionKeyVersionException,
"Unknown encryption key", 0x0011)
56DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, EncryptionKeyContainerValidationException,
"Encryption key container validation error", 0x0012)
57DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, DataIntegrityObjectDuplicatedException,
"Duplicated data integrity object", 0x0013)
58DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, MalformedDataIntegrityObjectException,
"Malformed data integrity object", 0x0014)
59DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, InvalidDataIntegrityObjectChecksumException,
"Invalid data integrity object checksum", 0x0015)
60DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, DataIntegrityObjectMismatchEncKeyException,
"User key does not match with author public key in data integrity object", 0x0016)
61DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, DataIntegrityObjectInvalidSignatureException,
"Invalid data integrity object signature", 0x0017)
62DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, KeyProviderRequestCompletedException,
"KeyProvider request completed", 0x0018)
63DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, MalformedVerifierResponseException,
"Malformed verifier response", 0x0019)
64DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, UnknownModuleEncryptionKeyException,
"Module's enc key with given keyId does not exist.", 0x0020)
65DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, ModulePublicDataMismatchException,
"Module public data mismatch", 0x0021)
66DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, InvalidEncryptedModuleDataVersionException,
"Invalid version of encrypted module data", 0x0022)
67DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, UnknownModuleFormatException,
"Unknown module format", 0x0023)
68DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, InvalidSubscriptionQueryException,
"Invalid subscriptionQuery", 0x00024)
69DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, InvalidSingletonsHolderStateException,
"Invalid Singletons Holder state", 0x00025)
71DECLARE_SCOPE_ENDPOINT_EXCEPTION(EndpointConnectionException,
"Unknown endpoint connection exception",
"Connection", 0x0002)
72DECLARE_ENDPOINT_EXCEPTION(EndpointConnectionException, NotInitializedException,
"Endpoint not initialized", 0x0001)
73DECLARE_ENDPOINT_EXCEPTION(EndpointConnectionException, CannotExtractLibPlatformDisconnectedEventException,
"Cannot extract LibPlatformDisconnectedEvent", 0x0002)
74DECLARE_ENDPOINT_EXCEPTION(EndpointConnectionException, CannotExtractLibConnectedEventException,
"Cannot extract LibConnectedEvent", 0x0003)
75DECLARE_ENDPOINT_EXCEPTION(EndpointConnectionException, CannotExtractLibDisconnectedEventException,
"Cannot extract LibDisconnectedEvent", 0x0004)
76DECLARE_ENDPOINT_EXCEPTION(EndpointConnectionException, DataBiggerThanDeclaredException,
"Data bigger than declared", 0x0005)
77DECLARE_ENDPOINT_EXCEPTION(EndpointConnectionException, DataSmallerThanDeclaredException,
"Data smaller than declared", 0x0006)
78DECLARE_ENDPOINT_EXCEPTION(EndpointConnectionException, DataDifferentThanDeclaredException,
"Data different than declared", 0x0007)
79DECLARE_ENDPOINT_EXCEPTION(EndpointConnectionException, CannotExtractLibBreakEventException,
"Cannot extract LibBreakEvent", 0x0008)
80DECLARE_ENDPOINT_EXCEPTION(EndpointConnectionException, ServerVersionMismatchException,
"The Bridge Server and the PrivMX Endpoint library versions mismatch", 0x0009)
81DECLARE_ENDPOINT_EXCEPTION(EndpointConnectionException, CannotExtractCollectionChangedEventException,
"Cannot extract CollectionChangedEvent", 0x000A)
82DECLARE_ENDPOINT_EXCEPTION(EndpointConnectionException, CannotExtractContextUserAddedEventException,
"Cannot extract ContextUserAddedEvent", 0x000B)
83DECLARE_ENDPOINT_EXCEPTION(EndpointConnectionException, CannotExtractContextUserRemovedEventException,
"Cannot extract ContextUserRemovedEvent", 0x000C)
84DECLARE_ENDPOINT_EXCEPTION(EndpointConnectionException, CannotExtractContextUsersStatusChangedEventException,
"Cannot extract ContextUsersStatusChangedEvent", 0x000D)
85DECLARE_ENDPOINT_EXCEPTION(EndpointConnectionException, NotConnectedException,
"Endpoint is not connected or not initialized", 0x000E)
86DECLARE_ENDPOINT_EXCEPTION(EndpointConnectionException, SessionExpiredException,
"Endpoint session is expired", 0x000F)
92#undef DECLARE_SCOPE_ENDPOINT_EXCEPTION
93#undef DECLARE_ENDPOINT_EXCEPTION