Ditto 4.6.0
Loading...
Searching...
No Matches
Errors.hpp
1#ifndef _DITTO_ERRORS_
2#define _DITTO_ERRORS_
3
4#include <exception>
5#include <string>
6
7struct dittoffi_error;
8typedef dittoffi_error dittoffi_error_t;
9
10#define DEFINE_EXCEPTION_CLASS(EXCEPTION_NAME, ...) \
11 class EXCEPTION_NAME : public std::exception { \
12 __VA_ARGS__ \
13 std::string message; \
14 EXCEPTION_NAME(); \
15 \
16 public: \
17 const char *what() const noexcept override { return message.c_str(); } \
18 };
19
20namespace ditto {
21
28class DittoError : public std::exception {
29 std::string message;
30
31public:
32 DittoError();
33 DittoError(dittoffi_error_t *ffi_error);
34 explicit DittoError(std::string msg);
35
41 const char *what() const noexcept override;
42};
43
44// MARK: - More specific errors
45
46// MARK: - Attachment fetch errors
47
48DEFINE_EXCEPTION_CLASS(AttachmentNotFoundError,
49 friend class AttachmentFetcherCtx;)
50DEFINE_EXCEPTION_CLASS(AttachmentTokenInvalidError,
51 friend class AttachmentFetcherCtx;)
52DEFINE_EXCEPTION_CLASS(FailedToFetchAttachmentError,
53 friend class AttachmentFetcherCtx;)
54
55// MARK: - Attachment creation errors
56
57DEFINE_EXCEPTION_CLASS(AttachmentFilePermissionDeniedError, friend class Store;)
58DEFINE_EXCEPTION_CLASS(AttachmentFileNotFoundError, friend class Store;)
59DEFINE_EXCEPTION_CLASS(FailedToCreateAttachmentError, friend class Store;)
60
61} // namespace ditto
62
63#endif
All errors that are thrown by the Ditto SDK are wrapped as a DittoError.
Definition Errors.hpp:28
const char * what() const noexcept override
Returns the explanatory string.
Definition Errors.cpp:50
Provides access to Collections and a write transaction API.
Definition Store.hpp:29
Definition Arc.hpp:10