C++ edjLibrary SDK
Loading...
Searching...
No Matches
error.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "http.hpp"
4
5namespace edjx {
6
8namespace error {
9
14 enum class HttpError {
16 Success = 0,
41
48 };
49
56 inline std::string to_string(HttpError e) {
57 switch (e) {
59 return "HTTP: success";
61 return "HTTP: unknown error";
63 return "HTTP: error in SDK function";
65 return "HTTP: invalid header name";
67 return "HTTP: invalid header value";
69 return "HTTP: header name length exceeds limit";
71 return "HTTP: header value length exceeds limit";
73 return "HTTP: http body too large error";
75 return "HTTP: URI value invalid";
77 return "HTTP: URI value exceeds limit";
79 return "HTTP: invalid fetch HTTP method";
81 return "HTTP: invalid response status code";
83 return "HTTP: invalid HTTP version";
84
86 return "Fetch: HTTP fetch response not found";
88 return "Fetch: HTTP fetch request failed";
90 return "HTTP: Channel closed";
91 }
92 }
93
98 enum class KVError {
100 Success = 0,
102 Unknown,
104 NotFound,
107 };
108
115 inline std::string to_string(KVError e) {
116 switch (e) {
117 case KVError::Success:
118 return "KV: success";
119 case KVError::Unknown:
120 return "KV: unknown";
122 return "KV: key not found";
124 return "KV: unauthorized";
125 }
126 }
127
132 enum class StorageError {
134 Success = 0,
159
164 };
165
172 inline std::string to_string(StorageError e) {
173 switch (e) {
175 return "Storage: success";
177 return "Storage: error occured in SDK library";
179 return "Storage: empty content";
181 return "Storage: missing query param 'file_name'";
183 return "Storage: bucket_id is deleted";
185 return "Storage: missing query param 'bucket_id'";
187 return "Storage: internal error";
189 return "Storage: bucket/content not found";
191 return "Storage: unauthorized";
193 return "Storage: missing attributes";
195 return "Storage: content does not exist or was deleted";
197 return "Storage: invalid attributes";
199 return "Storage: Resource limit exceeded";
200
202 return "Storage: Storage response not found";
204 return "Storage: Storage channel closed";
205 }
206 }
207
215 switch (e) {
217 return 200;
223 return 400; //HTTP_STATUS_BAD_REQUEST;
227 return 404; //HTTP_STATUS_NOT_FOUND;
229 return 403; //HTTP_STATUS_FORBIDDEN;
231 return 422; //HTTP_STATUS_UNPROCESSABLE_ENTITY,
236 return 500; //HTTP_STATUS_INTERNAL_SERVER_ERROR;
237 }
238 }
239
243 enum class StreamError {
245 Success = 0,
249 Unknown,
264 };
265
266 inline std::string to_string(StreamError e) {
267 switch (e) {
269 return "Stream: success";
271 return "Stream: end of stream";
273 return "Stream: unknown error";
275 return "Stream: system error";
277 return "Stream: stream not found";
279 return "Stream: stream channel is closed";
281 return "Stream: read attempted on write stream";
283 return "Stream: write attempted on read stream";
285 return "Stream: stream is closed";
287 return "Stream: stream chunk is too large";
288 }
289 }
290
291}}
StreamError
Enum that describes values returned by streaming functions.
Definition: error.hpp:243
@ StreamChunkTooLarge
Streamed chunk exceeds size limits.
@ ReadOnWriteStream
Read operation was attempted on a write-only stream.
@ Success
Stream function completed successfully.
@ Unknown
An unknown error occurred.
@ StreamClosed
Stream was already closed.
@ StreamChannelClosed
Stream channel has already been closed.
@ StreamNotFound
Requested stream was not found.
@ WriteOnReadStream
Write operation was attempted on a read-only stream.
@ SystemError
System error occurred.
@ EndOfStream
End of stream was reached.
edjx::http::HttpStatusCode to_http_status_code(StorageError e)
Convert an edjx::error::StorageError into an HTTP status code.
Definition: error.hpp:214
HttpError
Enum describing return values of functions that correspond to HTTP modules.
Definition: error.hpp:14
@ HTTPBodyTooLarge
HTTP body exceeds prescribed limits.
@ HeaderInvalidValue
Invalid header value.
@ UriTooLarge
URI is too long.
@ HeaderTooLargeName
Header name is too long.
@ UriInvalid
Invalid URI.
@ Success
Operation was successful.
@ HTTPFetchResponseNotFound
HTTP fetch response not found.
@ HTTPChannelClosed
HTTP Channel is closed.
@ HeaderInvalidName
Invalid header name.
@ HeaderTooLargeValue
Header value is too long.
@ HTTPInvalidMethod
An invalid HTTP method was provided.
@ HTTPFetchRequestFailed
HTTP fetch request failed.
@ SystemError
An error occured in the SDK library.
@ UnknownError
An unknown error occured while performing the request.
@ HTTPInvalidStatusCode
An invalid HTTP status code was provided.
@ HTTPInvalidVersion
An invalid HTTP version was provided.
KVError
Enum describing return values of functions that correspond to kv modules.
Definition: error.hpp:98
@ NotFound
The value associated with the key could not be found.
@ Success
KV operation was successful.
@ Unknown
An unknown error has ocurred while trying to perform a KV store operation.
@ UnAuthorized
This application is not authorized to access this key.
std::string to_string(HttpError e)
Returns a string representation of HttpError.
Definition: error.hpp:56
StorageError
Enum describing return values of functions that correspond to storage modules.
Definition: error.hpp:132
@ InvalidAttributes
The attributes are invalid.
@ EmptyContent
Content is required.
@ MissingAttributes
Attributes are required.
@ DeletedBucketID
The bucket id is deleted.
@ Success
Storage operation was successful.
@ ResourceLimit
Resource limit exceeded.
@ StorageChannelClosed
Storage channel closed.
@ InternalError
An internal error occured while performing the request.
@ MissingFileName
File name is required.
@ UnAuthorized
The credentials or policies entered are incorrect. Request could not be performed.
@ SystemError
An error occured in the SDK library.
@ ContentDeleted
The required content does not exist or has been deleted.
@ StorageResponseNotFound
Storage response not found.
@ ContentNotFound
The content or bucket wasn't found on the store.
@ MissingBucketID
Bucket ID is required.
uint16_t HttpStatusCode
HTTP status code (e.g., value 200 means OK, value 404 means Not Found)
Definition: http.hpp:60
Definition: error.hpp:5