diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-08-20 13:56:23 -0400 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-08-20 13:56:23 -0400 |
commit | 69fc8d805396b889b5e8c1c88e8129d93db77d29 (patch) | |
tree | 6b807bd9332c65b65066e247d4d00fd5e4118d2e /src/codes.cpp | |
parent | 442f1ee071152be04c4184473ddfee5040795b76 (diff) | |
download | libtwittercpp-69fc8d805396b889b5e8c1c88e8129d93db77d29.tar.gz libtwittercpp-69fc8d805396b889b5e8c1c88e8129d93db77d29.tar.bz2 libtwittercpp-69fc8d805396b889b5e8c1c88e8129d93db77d29.zip |
Updated API to use exceptions and make tweet/user objects more helpful
Diffstat (limited to 'src/codes.cpp')
-rw-r--r-- | src/codes.cpp | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/src/codes.cpp b/src/codes.cpp index 9639d5d..7805c7a 100644 --- a/src/codes.cpp +++ b/src/codes.cpp | |||
@@ -1,24 +1,17 @@ | |||
1 | #include "codes.h" | 1 | #include "codes.h" |
2 | #include <sstream> | ||
2 | 3 | ||
3 | std::ostream& operator<<(std::ostream& os, twitter::response r) | 4 | namespace twitter { |
4 | { | 5 | |
5 | switch (r) | 6 | const char* invalid_response::WHAT_TEXT = "Invalid response data received from Twitter"; |
7 | const char* connection_error::WHAT_TEXT = "Error connecting to Twitter"; | ||
8 | |||
9 | std::string unknown_error::generateMessage(int response_code) | ||
6 | { | 10 | { |
7 | case twitter::response::ok: return os << "OK"; | 11 | std::ostringstream msgbuilder; |
8 | case twitter::response::curl_error: return os << "Curl Error"; | 12 | msgbuilder << "Unknown error (HTTP " << response_code << ")"; |
9 | case twitter::response::bad_auth: return os << "Bad Auth"; | 13 | |
10 | case twitter::response::limited: return os << "Rate Limit Exceeded"; | 14 | return msgbuilder.str(); |
11 | case twitter::response::server_error: return os << "Twitter Server Error"; | ||
12 | case twitter::response::server_unavailable: return os << "Twitter Is Down"; | ||
13 | case twitter::response::server_overloaded: return os << "Twitter Is Over Capacity"; | ||
14 | case twitter::response::server_timeout: return os << "Twitter Connection Timed Out"; | ||
15 | case twitter::response::suspended: return os << "Authenticated User Is Suspended"; | ||
16 | case twitter::response::bad_token: return os << "Invalid Or Expired Access Token"; | ||
17 | case twitter::response::duplicate_status: return os << "Duplicate Status"; | ||
18 | case twitter::response::suspected_spam: return os << "Request Looks Automated"; | ||
19 | case twitter::response::write_restricted: return os << "Cannot Perform Write"; | ||
20 | case twitter::response::bad_length: return os << "Message Body Too Long"; | ||
21 | case twitter::response::unknown_error: return os << "Unknown Error"; | ||
22 | case twitter::response::invalid_media: return os << "Invalid Media"; | ||
23 | } | 15 | } |
24 | } | 16 | |
17 | }; | ||