about summary refs log tree commit diff stats
path: root/src/codes.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/codes.h')
-rw-r--r--src/codes.h108
1 files changed, 54 insertions, 54 deletions
diff --git a/src/codes.h b/src/codes.h index baf4f8f..b8812df 100644 --- a/src/codes.h +++ b/src/codes.h
@@ -5,179 +5,179 @@
5#include <string> 5#include <string>
6 6
7namespace twitter { 7namespace twitter {
8 8
9 class twitter_error : public std::runtime_error { 9 class twitter_error : public std::runtime_error {
10 public: 10 public:
11 11
12 using std::runtime_error::runtime_error; 12 using std::runtime_error::runtime_error;
13 }; 13 };
14 14
15 class bad_auth : public twitter_error { 15 class bad_auth : public twitter_error {
16 public: 16 public:
17 17
18 using twitter_error::twitter_error; 18 using twitter_error::twitter_error;
19 }; 19 };
20 20
21 class invalid_response : public twitter_error { 21 class invalid_response : public twitter_error {
22 public: 22 public:
23 23
24 static const char* WHAT_TEXT; 24 static const char* WHAT_TEXT;
25 25
26 explicit invalid_response(std::string response) noexcept 26 explicit invalid_response(std::string response) noexcept
27 : twitter_error(WHAT_TEXT), _response(std::move(response)) 27 : twitter_error(WHAT_TEXT), _response(std::move(response))
28 { 28 {
29 } 29 }
30 30
31 const std::string& getResponse() const noexcept 31 const std::string& getResponse() const noexcept
32 { 32 {
33 return _response; 33 return _response;
34 } 34 }
35 35
36 private: 36 private:
37 37
38 std::string _response; 38 std::string _response;
39 }; 39 };
40 40
41 class account_suspended : public twitter_error { 41 class account_suspended : public twitter_error {
42 public: 42 public:
43 43
44 using twitter_error::twitter_error; 44 using twitter_error::twitter_error;
45 }; 45 };
46 46
47 class rate_limit_exceeded : public twitter_error { 47 class rate_limit_exceeded : public twitter_error {
48 public: 48 public:
49 49
50 using twitter_error::twitter_error; 50 using twitter_error::twitter_error;
51 }; 51 };
52 52
53 class update_limit_exceeded : public twitter_error { 53 class update_limit_exceeded : public twitter_error {
54 public: 54 public:
55 55
56 using twitter_error::twitter_error; 56 using twitter_error::twitter_error;
57 }; 57 };
58 58
59 class bad_token : public twitter_error { 59 class bad_token : public twitter_error {
60 public: 60 public:
61 61
62 using twitter_error::twitter_error; 62 using twitter_error::twitter_error;
63 }; 63 };
64 64
65 class server_overloaded : public twitter_error { 65 class server_overloaded : public twitter_error {
66 public: 66 public:
67 67
68 using twitter_error::twitter_error; 68 using twitter_error::twitter_error;
69 }; 69 };
70 70
71 class server_error : public twitter_error { 71 class server_error : public twitter_error {
72 public: 72 public:
73 73
74 using twitter_error::twitter_error; 74 using twitter_error::twitter_error;
75 }; 75 };
76 76
77 class bad_length : public twitter_error { 77 class bad_length : public twitter_error {
78 public: 78 public:
79 79
80 using twitter_error::twitter_error; 80 using twitter_error::twitter_error;
81 }; 81 };
82 82
83 class duplicate_status : public twitter_error { 83 class duplicate_status : public twitter_error {
84 public: 84 public:
85 85
86 using twitter_error::twitter_error; 86 using twitter_error::twitter_error;
87 }; 87 };
88 88
89 class suspected_spam : public twitter_error { 89 class suspected_spam : public twitter_error {
90 public: 90 public:
91 91
92 using twitter_error::twitter_error; 92 using twitter_error::twitter_error;
93 }; 93 };
94 94
95 class write_restricted : public twitter_error { 95 class write_restricted : public twitter_error {
96 public: 96 public:
97 97
98 using twitter_error::twitter_error; 98 using twitter_error::twitter_error;
99 }; 99 };
100 100
101 class invalid_media : public twitter_error { 101 class invalid_media : public twitter_error {
102 public: 102 public:
103 103
104 using twitter_error::twitter_error; 104 using twitter_error::twitter_error;
105 }; 105 };
106 106
107 class server_unavailable : public twitter_error { 107 class server_unavailable : public twitter_error {
108 public: 108 public:
109 109
110 using twitter_error::twitter_error; 110 using twitter_error::twitter_error;
111 }; 111 };
112 112
113 class server_timeout : public twitter_error { 113 class server_timeout : public twitter_error {
114 public: 114 public:
115 115
116 using twitter_error::twitter_error; 116 using twitter_error::twitter_error;
117 }; 117 };
118 118
119 class unknown_error : public twitter_error { 119 class unknown_error : public twitter_error {
120 public: 120 public:
121 121
122 unknown_error(int response_code, std::string response_data) 122 unknown_error(int response_code, std::string response_data)
123 : twitter_error(generateMessage(response_code)), 123 : twitter_error(generateMessage(response_code)),
124 _response_code(response_code), 124 _response_code(response_code),
125 _response_data(std::move(response_data)) 125 _response_data(std::move(response_data))
126 { 126 {
127 } 127 }
128 128
129 int getResponseCode() const noexcept 129 int getResponseCode() const noexcept
130 { 130 {
131 return _response_code; 131 return _response_code;
132 } 132 }
133 133
134 const std::string& getResponse() const noexcept 134 const std::string& getResponse() const noexcept
135 { 135 {
136 return _response_data; 136 return _response_data;
137 } 137 }
138 138
139 private: 139 private:
140 140
141 static std::string generateMessage(int response_code); 141 static std::string generateMessage(int response_code);
142 142
143 int _response_code; 143 int _response_code;
144 std::string _response_data; 144 std::string _response_data;
145 }; 145 };
146 146
147 class connection_error : public twitter_error { 147 class connection_error : public twitter_error {
148 public: 148 public:
149 149
150 static const char* WHAT_TEXT; 150 static const char* WHAT_TEXT;
151 151
152 connection_error() noexcept : twitter_error(WHAT_TEXT) 152 connection_error() noexcept : twitter_error(WHAT_TEXT)
153 { 153 {
154 } 154 }
155 }; 155 };
156 156
157 class invalid_member : public std::domain_error { 157 class invalid_member : public std::domain_error {
158 public: 158 public:
159 159
160 using std::domain_error::domain_error; 160 using std::domain_error::domain_error;
161 }; 161 };
162 162
163 class malformed_object : public invalid_response { 163 class malformed_object : public invalid_response {
164 public: 164 public:
165 165
166 malformed_object(std::string type, std::string data) noexcept 166 malformed_object(std::string type, std::string data) noexcept
167 : invalid_response(std::move(data)), _type(std::move(type)) 167 : invalid_response(std::move(data)), _type(std::move(type))
168 { 168 {
169 } 169 }
170 170
171 const std::string& getType() const noexcept 171 const std::string& getType() const noexcept
172 { 172 {
173 return _type; 173 return _type;
174 } 174 }
175 175
176 private: 176 private:
177 177
178 std::string _type; 178 std::string _type;
179 }; 179 };
180 180
181}; 181};
182 182
183#endif /* end of include guard: CODES_H_05838D39 */ 183#endif /* end of include guard: CODES_H_05838D39 */