blob: baf4f8f9b1ca3032c1069aeda8278b1201524de6 (
plain) (
blame)
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
#ifndef CODES_H_05838D39
#define CODES_H_05838D39
#include <stdexcept>
#include <string>
namespace twitter {
class twitter_error : public std::runtime_error {
public:
using std::runtime_error::runtime_error;
};
class bad_auth : public twitter_error {
public:
using twitter_error::twitter_error;
};
class invalid_response : public twitter_error {
public:
static const char* WHAT_TEXT;
explicit invalid_response(std::string response) noexcept
: twitter_error(WHAT_TEXT), _response(std::move(response))
{
}
const std::string& getResponse() const noexcept
{
return _response;
}
private:
std::string _response;
};
class account_suspended : public twitter_error {
public:
using twitter_error::twitter_error;
};
class rate_limit_exceeded : public twitter_error {
public:
using twitter_error::twitter_error;
};
class update_limit_exceeded : public twitter_error {
public:
using twitter_error::twitter_error;
};
class bad_token : public twitter_error {
public:
using twitter_error::twitter_error;
};
class server_overloaded : public twitter_error {
public:
using twitter_error::twitter_error;
};
class server_error : public twitter_error {
public:
using twitter_error::twitter_error;
};
class bad_length : public twitter_error {
public:
using twitter_error::twitter_error;
};
class duplicate_status : public twitter_error {
public:
using twitter_error::twitter_error;
};
class suspected_spam : public twitter_error {
public:
using twitter_error::twitter_error;
};
class write_restricted : public twitter_error {
public:
using twitter_error::twitter_error;
};
class invalid_media : public twitter_error {
public:
using twitter_error::twitter_error;
};
class server_unavailable : public twitter_error {
public:
using twitter_error::twitter_error;
};
class server_timeout : public twitter_error {
public:
using twitter_error::twitter_error;
};
class unknown_error : public twitter_error {
public:
unknown_error(int response_code, std::string response_data)
: twitter_error(generateMessage(response_code)),
_response_code(response_code),
_response_data(std::move(response_data))
{
}
int getResponseCode() const noexcept
{
return _response_code;
}
const std::string& getResponse() const noexcept
{
return _response_data;
}
private:
static std::string generateMessage(int response_code);
int _response_code;
std::string _response_data;
};
class connection_error : public twitter_error {
public:
static const char* WHAT_TEXT;
connection_error() noexcept : twitter_error(WHAT_TEXT)
{
}
};
class invalid_member : public std::domain_error {
public:
using std::domain_error::domain_error;
};
class malformed_object : public invalid_response {
public:
malformed_object(std::string type, std::string data) noexcept
: invalid_response(std::move(data)), _type(std::move(type))
{
}
const std::string& getType() const noexcept
{
return _type;
}
private:
std::string _type;
};
};
#endif /* end of include guard: CODES_H_05838D39 */
|