1#ifndef _PRIVMXLIB_ENDPOINT_CONVERTED_EXT_EXCEPTION_HPP_
2#define _PRIVMXLIB_ENDPOINT_CONVERTED_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 { \
38DECLARE_SCOPE_ENDPOINT_EXCEPTION(EndpointServerRequestException,
"Invalid request exception",
"Server request", 0xFFFF)
39DECLARE_ENDPOINT_EXCEPTION(EndpointServerRequestException, ParseErrorException,
"Parse error", 0x8043)
40DECLARE_ENDPOINT_EXCEPTION(EndpointServerRequestException, InvalidRequestAException,
"Invalid request", 0x80A8)
41DECLARE_ENDPOINT_EXCEPTION(EndpointServerRequestException, MethodNotFoundException,
"Method not found", 0x80A7)
42DECLARE_ENDPOINT_EXCEPTION(EndpointServerRequestException, InvalidParamsException,
"Invalid params", 0x80A6)
43DECLARE_ENDPOINT_EXCEPTION(EndpointServerRequestException, InternalErrorException,
"Internal error", 0x80A5)
44DECLARE_ENDPOINT_EXCEPTION(EndpointServerRequestException, InvalidRequestBException,
"Invalid request", 0x80A4)
45DECLARE_ENDPOINT_EXCEPTION(EndpointServerRequestException, InvalidRequestCException,
"Invalid request", 0x80A3)
47DECLARE_SCOPE_ENDPOINT_EXCEPTION(EndpointServerException,
"Unknown server exception",
"Server", 0xF000)
48DECLARE_ENDPOINT_EXCEPTION(EndpointServerException, UserDoesNotExistException,
"User doesn't exist", 0x0009)
49DECLARE_ENDPOINT_EXCEPTION(EndpointServerException, AccessDeniedException,
"Access denied", 0x0030)
50DECLARE_ENDPOINT_EXCEPTION(EndpointServerException, InvalidKeyException,
"Invalid key", 0x0070)
51DECLARE_ENDPOINT_EXCEPTION(EndpointServerException, ThreadDoesNotExistException,
"Thread does not exist", 0x6001)
52DECLARE_ENDPOINT_EXCEPTION(EndpointServerException, InvalidThreadKeyException,
"Invalid thread key", 0x6002)
53DECLARE_ENDPOINT_EXCEPTION(EndpointServerException, ThreadMessageDoesNotExistException,
"Thread message does not exist", 0x600D)
54DECLARE_ENDPOINT_EXCEPTION(EndpointServerException, InvalidKeyIdException,
"Invalid key id", 0x6015)
55DECLARE_ENDPOINT_EXCEPTION(EndpointServerException, ContextDoesNotExistException,
"Context does not exist", 0x6116)
56DECLARE_ENDPOINT_EXCEPTION(EndpointServerException, StoreDoesNotExistException,
"Store does not exist", 0x6117)
57DECLARE_ENDPOINT_EXCEPTION(EndpointServerException, StoreFileDoesNotExistException,
"Store file does not exist", 0x6118)
58DECLARE_ENDPOINT_EXCEPTION(EndpointServerException, StoreFileVersionMismatchException,
"Store file version mismatch", 0x6128)
59DECLARE_ENDPOINT_EXCEPTION(EndpointServerException, InboxDoesNotExistException,
"Inbox does not exist", 0x611E)
60DECLARE_ENDPOINT_EXCEPTION(EndpointServerException, KvdbDoesNotExistException,
"Kvdb does not exist", 0x613C)
61DECLARE_ENDPOINT_EXCEPTION(EndpointServerException, KvdbEntryDoesNotExistException,
"Kvdb entry does not exist", 0x613D)
67DECLARE_SCOPE_ENDPOINT_EXCEPTION(EndpointNotConnectedException,
"Unknown Network Exception",
"NetConnection", 0xE001)
68DECLARE_ENDPOINT_EXCEPTION(EndpointNotConnectedException, NotConnectedException,
"RpcGateway is not connected", 0x0001)
69DECLARE_ENDPOINT_EXCEPTION(EndpointNotConnectedException, WebsocketDisconnectedException,
"Websocket disconnected", 0x0002)
70DECLARE_ENDPOINT_EXCEPTION(EndpointNotConnectedException, NoMessageReceivedException,
"No message received, http session lost", 0x0003)
72DECLARE_SCOPE_ENDPOINT_EXCEPTION(EndpointServerException,
"Unknown Server Exception",
"Server", 0xE002)
73DECLARE_ENDPOINT_EXCEPTION(EndpointServerException, InvalidHttpStatusException,
"Unexpected server data", 0x0001)
74DECLARE_ENDPOINT_EXCEPTION(EndpointServerException, UnexpectedServerDataException,
"Unknown Server Exception", 0x0002)
76DECLARE_SCOPE_ENDPOINT_EXCEPTION(EndpointRpcException,
"Unknown Rpc exception",
"Rpc", 0xE0A4)
77DECLARE_ENDPOINT_EXCEPTION(EndpointRpcException, TicketsCountIsEqualZeroException,
"Tickets count is equal zero", 0x0001)
78DECLARE_ENDPOINT_EXCEPTION(EndpointRpcException, WsConnectException,
"wsConnect", 0x0002)
79DECLARE_ENDPOINT_EXCEPTION(EndpointRpcException, WsSend1Exception,
"WsSend1", 0x0003)
80DECLARE_ENDPOINT_EXCEPTION(EndpointRpcException, WebSocketInvalidPayloadLengthException,
"Invalid payload length", 0x0004)
81DECLARE_ENDPOINT_EXCEPTION(EndpointRpcException, InvalidWebSocketRequestIdException,
"Invalid WebSocket request id", 0x0005)
82DECLARE_ENDPOINT_EXCEPTION(EndpointRpcException, HttpConnectException,
"httpConnect", 0x0006)
83DECLARE_ENDPOINT_EXCEPTION(EndpointRpcException, HttpRequestException,
"httpRequest", 0x0007)
84DECLARE_ENDPOINT_EXCEPTION(EndpointRpcException, WebSocketPingLoopStoppedException,
"Ping loop stopped", 0x0008)
85DECLARE_ENDPOINT_EXCEPTION(EndpointRpcException, WebSocketPingTimeoutException,
"Ping timeout", 0x0009)
86DECLARE_ENDPOINT_EXCEPTION(EndpointRpcException, InvalidHandshakeStateException,
"Invalid handshake state", 0x000A)
87DECLARE_ENDPOINT_EXCEPTION(EndpointRpcException, IncorrectHashmailException,
"Incorrect hashmail", 0x000B)
88DECLARE_ENDPOINT_EXCEPTION(EndpointRpcException, UnexpectedEcdhePacketFromServerException,
"Unexpected ecdhe packet from server", 0x000C)
89DECLARE_ENDPOINT_EXCEPTION(EndpointRpcException, UnexpectedEcdhexPacketFromServerException,
"Unexpected ecdhex packet from server", 0x000D)
90DECLARE_ENDPOINT_EXCEPTION(EndpointRpcException, InvalidWsChannelIdException,
"Invalid wsChannelId", 0x000E)
91DECLARE_ENDPOINT_EXCEPTION(EndpointRpcException, ErrorDuringGettingHTTPChannelException,
"Error during getting HTTP channel", 0x000F)
92DECLARE_ENDPOINT_EXCEPTION(EndpointRpcException, ConnectionDestroyedException,
"Connection destroyed", 0x0010)
93DECLARE_ENDPOINT_EXCEPTION(EndpointRpcException, SessionLostException,
"Session lost", 0x0011)
94DECLARE_ENDPOINT_EXCEPTION(EndpointRpcException, ProbeFailException,
"Probe fail", 0x0012)
95DECLARE_ENDPOINT_EXCEPTION(EndpointRpcException, InvalidHostException,
"Invalid host", 0x0013)
96DECLARE_ENDPOINT_EXCEPTION(EndpointRpcException, WebsocketCannotBeMainChannelWhenItIsDisabledException,
"Websocket cannot be main channel when it is disabled", 0x0014)
97DECLARE_ENDPOINT_EXCEPTION(EndpointRpcException, RejectedException,
"Rejected", 0x0015)
98DECLARE_ENDPOINT_EXCEPTION(EndpointRpcException, FrameHeaderTagsAreNotEqualException,
"Frame header tags are not equal", 0x0016)
99DECLARE_ENDPOINT_EXCEPTION(EndpointRpcException, UnsupportedFrameVersionException,
"Unsupported frame version", 0x0017)
100DECLARE_ENDPOINT_EXCEPTION(EndpointRpcException, FrameMacsAreNotEqualException,
"Frame macs are not equal", 0x0018)
101DECLARE_ENDPOINT_EXCEPTION(EndpointRpcException, InvalidNextReadStateException,
"Invalid next read state", 0x0019)
102DECLARE_ENDPOINT_EXCEPTION(EndpointRpcException, WriteStateIsNotInitializedException,
"Write state is not initialized", 0x001A)
103DECLARE_ENDPOINT_EXCEPTION(EndpointRpcException, TicketHandshakeErrorException,
"Ticket handshake error", 0x001B)
109DECLARE_SCOPE_ENDPOINT_EXCEPTION(EndpointLibException,
"Unknown Lib exception",
"Lib", 0xE003)
110DECLARE_ENDPOINT_EXCEPTION(EndpointLibException, CannotStringifyVarException,
"Cannot stringify var", 0x0001)
111DECLARE_ENDPOINT_EXCEPTION(EndpointLibException, KeyNotExistException,
"Key not exist", 0x0002)
112DECLARE_ENDPOINT_EXCEPTION(EndpointLibException, VarIsNotObjectException,
"Var is not object", 0x0003)
113DECLARE_ENDPOINT_EXCEPTION(EndpointLibException, VarIsNotArrayException,
"Var is not array", 0x0004)
114DECLARE_ENDPOINT_EXCEPTION(EndpointLibException, OperationCancelledException,
"Operation canceled", 0x0005)
115DECLARE_ENDPOINT_EXCEPTION(EndpointLibException, NotImplementedException,
"Not implemented", 0x0006)
116DECLARE_ENDPOINT_EXCEPTION(EndpointLibException, InvalidVersionFormatException,
"Invalid version format", 0x0007);
122DECLARE_SCOPE_ENDPOINT_EXCEPTION(EndpointCryptoException,
"Unknown Crypto exception",
"Crypto", 0xE0A1)
123DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, UnsupportedKeyFormatException,
"Unsupported key format", 0x0001)
124DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, EmptyPointException,
"Empty point", 0x0002)
125DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, InvalidSignatureSizeException,
"Invalid signature size", 0x0003)
126DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, InvalidSignatureHeaderException,
"Invalid signature header", 0x0004)
127DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, ECCIsNotInitializedException,
"ECC is not initialized", 0x0005)
128DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, EmptyBNException,
"Empty BN", 0x0006)
129DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, WrongMessageSecurityTagException,
"Wrong message security tag", 0x0007)
130DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, DecryptInvalidKeyLengthException,
"Decrypt invalid key length", 0x0008)
131DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, MissingIvException,
"Missing iv", 0x0009)
132DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, UnknownDecryptionTypeException,
"Unknown decryption type", 0x000A)
133DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, UnsupportedHashAlgorithmException,
"Unsupported hash algorithm", 0x000B)
134DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, CryptoNotImplementedException,
"Not implemented", 0x000C)
135DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, InvalidStrengthException,
"Invalid strength", 0x000D)
136DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, InvalidEntropyException,
"Invalid entropy", 0x000E)
137DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, InvalidMnemonicException,
"Invalid mnemonic", 0x000F)
138DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, InvalidChecksumException,
"Invalid checksum", 0x0010)
139DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, EncryptInvalidKeyLengthException,
"Encrypt invalid key length", 0x0011)
140DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, OnlyHmacSHA256WithIvIsSupportedForAES256CBCException,
"Only hmac SHA-256 with iv is supported for AES-256-CBC", 0x0012)
141DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, CannotPassIvToDeterministicAES256CBCHmacSHA256Exception,
"Cannot pass iv to deterministic AES-256-CBC hmac SHA-256", 0x0014)
142DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, XTEAECBEncryptionDoesntSupportHmacAndIvException,
"XTEA-ECB encryption doesn't support hmac and iv", 0x0014)
143DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, UnsupportedEncryptionAlgorithmException,
"Unsupported encryption algorithm", 0x0015)
144DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, MissingRequiredSignatureException,
"Missing required signature", 0x0016)
145DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, InvalidFirstByteOfCipherException,
"Invalid first byte of cipher", 0x0017)
146DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, GivenPrivKeyDoesNotMatchException,
"Given priv key does not match", 0x0018)
147DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, UnsupportedAlgorithmException,
"Unsupported algorithm", 0x0019)
148DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, UnsupportedVersionException,
"Unsupported version", 0x001A)
149DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, IncorrectParamsException,
"Incorrect params", 0x001B)
150DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, InvalidHandshakeStateException,
"Invalid handshake state", 0x001C)
151DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, InvalidBNException,
"Invalid B N", 0x001D)
152DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, InvalidM2Exception,
"Invalid M2", 0x001E)
153DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, InvalidVersionException,
"Invalid version", 0x001F)
154DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, InvalidParentFingerprintException,
"Invalid parent fingerprint", 0x0020)
155DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, InvalidResultSizeException,
"Invalid result size", 0x0022)
156DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, InvalidNetworkException,
"Invalid network", 0x0023)
157DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, InvalidCompressionFlagException,
"Invalid network", 0x0024)
158DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, InvalidWIFPayloadLengthException,
"Invalid WIF payload length", 0x0025)
159DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, OpenSSLException,
"OpenSSL Exception", 0x0026)
160DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, PrivmxDriverCryptoException,
"privmxDrvCrypto Exception", 0x0027)
161DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, PrivmxDriverEccException,
"privmxDrvEcc Exception", 0x0028)
162DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, GivenPublicKeyDoesNotMatchWithSignatureException,
"DGiven public key does not match with signature", 0x0029)
163DECLARE_ENDPOINT_EXCEPTION(EndpointCryptoException, ExtKeyDoesNotHoldPrivateKeyException,
"Ext key does not hold private key", 0x002A)
165DECLARE_SCOPE_ENDPOINT_EXCEPTION(EndpointPrivFsException,
"Unknown PrivFs exception",
"PrivFs", 0xE0A3)
166DECLARE_ENDPOINT_EXCEPTION(EndpointPrivFsException, InvalidHostException,
"Invalid host", 0x0001)
167DECLARE_ENDPOINT_EXCEPTION(EndpointPrivFsException, NoCallbackForAdditionalLoginStepException,
"No callback for additional login step", 0x0002)
168DECLARE_ENDPOINT_EXCEPTION(EndpointPrivFsException, UnsupportedEmptyKeystoreException,
"Unsupported empty keystore", 0x0003)
169DECLARE_ENDPOINT_EXCEPTION(EndpointPrivFsException, DifferentIdentityException,
"Different identity", 0x0004)
170DECLARE_ENDPOINT_EXCEPTION(EndpointPrivFsException, UnsupportedMasterRecordVersionException,
"Unsupported masterRecord.version", 0x0005)
171DECLARE_ENDPOINT_EXCEPTION(EndpointPrivFsException, CannotDecryptLevel2OfMasterRecordException,
"Cannot decrypt level 2 of master record", 0x0006)
172DECLARE_ENDPOINT_EXCEPTION(EndpointPrivFsException, RpcProxyRequestNotImplementedException,
"Rpc proxy request not implemented", 0x0007)
173DECLARE_ENDPOINT_EXCEPTION(EndpointPrivFsException, UserDoesNotExistsException,
"User does not exists", 0x0008)
174DECLARE_ENDPOINT_EXCEPTION(EndpointPrivFsException, SenderCannotBeEmptyException,
"Sender cannot be empty", 0x0009)
175DECLARE_ENDPOINT_EXCEPTION(EndpointPrivFsException, SenderMustBeInstanceOfIdentityException,
"Sender must be instance of Identity", 0x000A)
176DECLARE_ENDPOINT_EXCEPTION(EndpointPrivFsException, MessageMustContainsAtLeastOneReceiverException,
"Message must contains at least one receiver", 0x000B)
177DECLARE_ENDPOINT_EXCEPTION(EndpointPrivFsException, InvalidSinkPrivateKeyException,
"Invalid sink private key", 0x000C)
178DECLARE_ENDPOINT_EXCEPTION(EndpointPrivFsException, PrivFsNotImplementedException,
"Not implemented", 0x000D)
179DECLARE_ENDPOINT_EXCEPTION(EndpointPrivFsException, MnemonicIsNotGeneratedYetException,
"Mnemonic is not generated yet", 0x000E)
180DECLARE_ENDPOINT_EXCEPTION(EndpointPrivFsException, InvalidResponseException,
"INVALID_RESPONSE", 0x000F)
181DECLARE_ENDPOINT_EXCEPTION(EndpointPrivFsException, UnsupportedPrivDataInfoVersionException,
"Unsupported privDataInfo version", 0x0010)
182DECLARE_ENDPOINT_EXCEPTION(EndpointPrivFsException, CosignerKeystoreStateAndUuidAreRequiredException,
"Cosigner 'keystore', 'state' and 'uuid' are required", 0x0011)
183DECLARE_ENDPOINT_EXCEPTION(EndpointPrivFsException, ExpectedDocumentsPacketExportClassException,
"Expected DocumentsPacket export class", 0x0012)
184DECLARE_ENDPOINT_EXCEPTION(EndpointPrivFsException, CannotGetPropertiesFromNonSrpKeySessionConnectionException,
"Cannot get properties from non srp/key/session connection", 0x0013)
185DECLARE_ENDPOINT_EXCEPTION(EndpointPrivFsException, CannotGetUsernameFromNonSrpKeySessionConnectionException,
"Cannot get username from non srp/key/session connection", 0x0014)
186DECLARE_ENDPOINT_EXCEPTION(EndpointPrivFsException, CannotReloginUserMismatchException,
"Cannot relogin - user mismatch", 0x0015)
187DECLARE_ENDPOINT_EXCEPTION(EndpointPrivFsException, ConnectionCannotBeRestoredBySessionException,
"Connection cannot be restored by session", 0x0016)
188DECLARE_ENDPOINT_EXCEPTION(EndpointPrivFsException, WorkerRunningException,
"Worker running", 0x0017)
195#undef DECLARE_SCOPE_ENDPOINT_EXCEPTION
196#undef DECLARE_ENDPOINT_EXCEPTION