37
37
// - src/qt/internal/unmarshal_error.cpp
40
\brief Base exception class for all server-side exceptions.
40
\brief Abstract base exception class for all server-side exceptions.
42
43
class UNITY_STORAGE_EXPORT StorageException : public std::exception
47
\brief Constructs a StorageException.
48
\param exception_type The concrete type name of the exception, such as "ConflictException".
49
\param error_message The error message text for the exception.
45
51
StorageException(std::string const& exception_type, std::string const& error_message);
48
54
~StorageException();
58
\brief Returns an error string.
59
\return The error message prefixed by the exception type, such as "ConflictException: ETag mismatch".
51
61
virtual char const* what() const noexcept override;
64
\brief Returns the exception type name.
65
\return The value of the <code>exception_type</code> parameter that was passed to the constructor.
53
67
std::string type() const;
70
\brief Returns the except error message.
71
\return The value of the <code>error_message</code> parameter that was passed to the constructor.
54
73
std::string error_message() const;
63
82
\brief Indicates errors in the communication between the storage provider and the cloud service.
84
Use this exception for unexpected communication errors, such as the remote server being unreachable
85
or returning garbled data.
65
88
class UNITY_STORAGE_EXPORT RemoteCommsException : public StorageException
92
\brief Construct a RemoteCommsException.
93
\param error_message The error message for the exception.
68
95
RemoteCommsException(std::string const& error_message);
69
96
~RemoteCommsException();
73
\brief Indicates that an item does not exist or could not be found.
100
\brief Indicates that an item does not exist.
102
Use this exception only if the remote cloud service has <i>authoritatively</i> indicated non-existence
103
(such as with an HTTP 404 response). Do not use this exception for non-authoritative errors, such as
75
107
class UNITY_STORAGE_EXPORT NotExistsException : public StorageException
111
\brief Construct a RemoteCommsException.
112
\param error_message The error message for the exception.
113
\param key The name or identity of the non-existent item.
78
115
NotExistsException(std::string const& error_message, std::string const& key);
79
116
~NotExistsException();
119
\brief Return the key.
120
\return The value of the <code>key</code> parameter that was passed to the constructor.
81
122
std::string key() const;
88
\brief Indicates that an item cannot be created because it exists already.
129
\brief Indicates that an item already exists.
131
Use this exception only if the remote cloud service has <i>authoritatively</i> indicated that an operation
132
cannot be carried out because an item exists already. Do not use this exception for non-authoritative errors,
133
such as timeouts or similar.
90
136
class UNITY_STORAGE_EXPORT ExistsException : public StorageException
140
\brief Construct an ExistsException.
141
\param error_message The error message for the exception.
142
\param identity The identity of the item.
143
\param name The name of the item.
93
145
ExistsException(std::string const& error_message, std::string const& identity, std::string const& name);
94
146
~ExistsException();
149
\brief Return the identity.
150
\return The value of the <code>identity</code> parameter that was passed to the constructor.
96
152
std::string native_identity() const;
155
\brief Return the name of the item.
156
\return The value of the <code>name</code> parameter that was passed to the constructor.
97
158
std::string name() const;
105
\brief Indicates that an upload or download detected a version mismatch.
166
\brief Indicates that an upload or download detected a ETag mismatch.
107
169
class UNITY_STORAGE_EXPORT ConflictException : public StorageException
173
\brief Construct a ConflictException.
174
\param error_message The error message for the exception.
110
176
ConflictException(std::string const& error_message);
111
177
~ConflictException();
115
\brief Indicates that an operation failed because the authentication credentials are invalid or expired.
181
\brief Indicates that an operation failed because the credentials are invalid or have expired.
117
183
A provider implementation must throw this exception if it cannot reach
118
its provider because the credentials are invalid. Do not throw this
184
its provider because the credentials are invalid. Do <i>not</i> throw this
119
185
exception if the credentials are valid, but an operation failed due to
120
186
insufficient permission for an item (such as an attempt to write to a
123
Typically, this will cause the request to be retried after refreshing
124
the authentication credentials, but may be returned to the client on
189
Typically, this exception will cause the runtime to retry the operation after refreshing
190
the credentials; the exception may be returned to the client on repeated failures.
127
192
\see PermissionException
129
195
class UNITY_STORAGE_EXPORT UnauthorizedException : public StorageException
199
\brief Construct an UnauthorizedException.
200
\param error_message The error message for the exception.
132
202
UnauthorizedException(std::string const& error_message);
133
203
~UnauthorizedException();
139
209
A provider implementation must throw this exception if it can
140
210
authenticate with its provider, but the provider denied the operation
141
211
due to insufficient permission for an item (such as an attempt to
142
write to a read-only file). Do not throw this exception for failure to
212
write to a read-only file). Do <i>not</i> throw this exception for failure to
143
213
authenticate with the provider.
145
215
\see UnauthorizedException
147
218
class UNITY_STORAGE_EXPORT PermissionException : public StorageException
222
\brief Construct a PermissionException.
223
\param error_message The error message for the exception.
150
225
PermissionException(std::string const& error_message);
151
226
~PermissionException();
155
\brief Indicates that an update failed because the provider ran out of space.
230
\brief Indicates that an update failed because the provider ran out of space or exceeded
231
the maximum number of files or folders.
157
234
class UNITY_STORAGE_EXPORT QuotaException : public StorageException
238
\brief Construct a QuotaException.
239
\param error_message The error message for the exception.
160
241
QuotaException(std::string const& error_message);
161
242
~QuotaException();
165
246
\brief Indicates that an upload or download was cancelled before it could complete.
247
\note Due to the way the provider API is structured, you will not ever need to throw this exception. It is provided for
248
completeness and to allow for provider implementations that do not use the storage framework API.
167
251
class UNITY_STORAGE_EXPORT CancelledException : public StorageException
255
\brief Construct a CancelledException.
256
\param error_message The error message for the exception.
170
258
CancelledException(std::string const& error_message);
171
259
~CancelledException();
175
\brief Indicates incorrect use of the API, such as calling methods in the wrong order.
263
\brief Indicates incorrect use of the API.
265
Use this exception for errors that the client could avoid, such as calling methods in the wrong order or attempting
266
to list the contents of file (as opposed to a folder).
267
\note Do <i>not</i> throw this exception to indicate arguments that are malformed or out of range.
268
\see InvalidArgumentException
177
270
class UNITY_STORAGE_EXPORT LogicException : public StorageException
274
\brief Construct a LogicException.
275
\param error_message The error message for the exception.
180
277
LogicException(std::string const& error_message);
181
278
~LogicException();
185
\brief Indicates an invalid parameter, such as a negative value when a positive one was
282
\brief Indicates an invalid parameter.
284
Use this exception for errors such as a negative parameter value when a positive one was
186
285
expected, or a string that does not parse correctly or is empty when it should be non-empty.
286
\note Do <i>not</i> throw this exception to indicate incorrect use of the API.
188
290
class UNITY_STORAGE_EXPORT InvalidArgumentException : public StorageException
294
\brief Construct an InvalidArgumentException.
295
\param error_message The error message for the exception.
191
297
InvalidArgumentException(std::string const& error_message);
192
298
~InvalidArgumentException();
196
\brief Indicates a system error, such as failure to create a file or folder,
197
or any other (usually non-recoverable) kind of error that should not arise during normal operation.
302
\brief Indicates a system error.
304
This is a generic "catch-all" exception that you can throw to indicate unexpected errors that do not fit into
305
any of the other categories. For example, ResourceException is appropriate to indicate out of
306
file descriptors, failure to locate a configuration file, or any other unexpected system error. You should
307
provide as much contextual information about such errors as possible. In particular, unexpected errors
308
typically need to be diagnosed from log files. This means that you should provide, at least, the full error
309
message you received from the cloud service (or the operating system), together with all other relevant
310
details, such as the name of the file, the URL of a failed request, any HTTP error information, and so on.
199
313
class UNITY_STORAGE_EXPORT ResourceException : public StorageException
317
\brief Construct an InvalidArgumentException.
318
\param error_message The error message for the exception.
319
\param error_code The system (or library) error code for the exception.
320
In case of system call failures, <code>error_code</code> should be the value of <code>errno</code>.
321
If the error code represents something else, such as a <code>QFileDevice::FileError</code>,
322
also indicate in the error message what that error code is; otherwise, it can be
323
impossible to diagnose a problem, especially when looking at log files after the fact.
202
325
ResourceException(std::string const& error_message, int error_code);
203
326
~ResourceException();
329
\brief Return the error code.
330
\return The value of the <code>error_code</code> parameter that was passed to the constructor.
205
332
int error_code() const noexcept;
212
\brief Indicates that the server side caught an exception that does not derive from
213
StorageException, such as a std::exception, or caught some other unknown type (such as `int`).
339
\brief Indicates that a provider threw an exception not derived from StorageException.
341
The runtime translates all exception that are thrown by a provider and that do not derive from StorageException
344
Do not throw this exception explicitly; is is a "catch-all" exception that the runtime uses to
345
indicate that something completely unexpected happened. (If a client receives this exception from your
346
provider, chances are that you have forgotten to handle an error condition somewhere.)
215
349
class UNITY_STORAGE_EXPORT UnknownException : public StorageException
353
\brief Construct an UnknownArgumentException.
354
\param error_message The error message for the exception. This is the string returned by <code>what()</code>
355
for <code>std::exception</code> or "Unknown exception" for exceptions that do not derive
356
from <code>std::exception</code>.
218
358
UnknownException(std::string const& error_message);
219
359
~UnknownException();