-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHttpError
More file actions
117 lines (100 loc) · 2.27 KB
/
HttpError
File metadata and controls
117 lines (100 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
* Copyright (C) 2021 Frank Mertens.
*
* Distribution and use is allowed under the terms of the GNU General Public License version 3
* (see CoreComponents/LICENSE-gpl-3.0).
*
*/
#include <cc/Exception>
#include <cc/HttpStatus>
#pragma once
namespace cc {
/** \class HttpError cc/HttpError
* \ingroup http_protocol
* \brief HTTP request could not be successfully processed
*/
class HttpError: public Exception
{
public:
/** Create a new HTTP error
*/
HttpError(HttpStatus status, const char *reason):
status_{status},
reason_{reason}
{}
/** \copybrief HttpStatus
*/
HttpStatus status() const { return status_; }
/** %Reason phrase
*/
const char *reason() const { return reason_; }
String message() const override { return reason_; }
private:
HttpStatus status_;
const char *reason_;
};
/** \class HttpBadRequest cc/HttpError
* \brief The request was syntactically maleformed
*/
class HttpBadRequest: public HttpError
{
public:
HttpBadRequest();
};
/** \class HttpForbidden cc/HttpError
* \brief Insufficient permissions to execute the request
*/
class HttpForbidden: public HttpError
{
public:
HttpForbidden();
};
/** \class HttpNotFound cc/HttpError
* \brief Requested resource could not be found
*/
class HttpNotFound: public HttpError
{
public:
HttpNotFound();
};
/** \class HttpRequestTimeout cc/HttpError
* \brief Connection has timed out
*/
class HttpRequestTimeout: public HttpError
{
public:
HttpRequestTimeout();
};
/** \class HttpPayloadTooLarge cc/HttpError
* \brief Message payload exceeded allowed upper limit
*/
class HttpPayloadTooLarge: public HttpError
{
public:
HttpPayloadTooLarge();
};
/** \class HttpInternalServerError cc/HttpError
* \brief Internal server malefunction
*/
class HttpInternalServerError: public HttpError
{
public:
HttpInternalServerError();
};
/** \class HttpUnsupportedVersion cc/HttpError
* \brief Request protocol version is not supported
*/
class HttpUnsupportedVersion: public HttpError
{
public:
HttpUnsupportedVersion();
};
/** \class HttpNotImplemented cc/HttpError
* \brief HTTP protocol feature not implemented
*/
class HttpNotImplemented: public HttpError
{
public:
HttpNotImplemented();
};
} // namespace cc