Slack: Handle 'account_inactive' error
This commit is contained in:
parent
a8128fde21
commit
5dd1aa90b4
3 changed files with 20 additions and 6 deletions
|
@ -21,12 +21,7 @@ class HTTPRequest : public Thread {
|
||||||
HTTPRequest(ThreadPool *tp, Type type, const std::string &url, Callback callback);
|
HTTPRequest(ThreadPool *tp, Type type, const std::string &url, Callback callback);
|
||||||
HTTPRequest(Type type, const std::string &url);
|
HTTPRequest(Type type, const std::string &url);
|
||||||
|
|
||||||
virtual ~HTTPRequest() {
|
virtual ~HTTPRequest();
|
||||||
if(curlhandle) {
|
|
||||||
curl_easy_cleanup(curlhandle);
|
|
||||||
curlhandle = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void setProxy(std::string, std::string, std::string, std::string);
|
void setProxy(std::string, std::string, std::string, std::string);
|
||||||
bool execute();
|
bool execute();
|
||||||
|
|
|
@ -21,6 +21,14 @@ HTTPRequest::HTTPRequest(Type type, const std::string &url) {
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HTTPRequest::~HTTPRequest() {
|
||||||
|
if (curlhandle) {
|
||||||
|
LOG4CXX_INFO(logger, "Cleaning up CURL handle");
|
||||||
|
curl_easy_cleanup(curlhandle);
|
||||||
|
curlhandle = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool HTTPRequest::init() {
|
bool HTTPRequest::init() {
|
||||||
curlhandle = curl_easy_init();
|
curlhandle = curl_easy_init();
|
||||||
if (curlhandle) {
|
if (curlhandle) {
|
||||||
|
@ -85,6 +93,7 @@ bool HTTPRequest::GET(std::string url, std::string &data) {
|
||||||
LOG4CXX_ERROR(logger, "CURL not initialized!")
|
LOG4CXX_ERROR(logger, "CURL not initialized!")
|
||||||
strcpy(curl_errorbuffer, "CURL not initialized!");
|
strcpy(curl_errorbuffer, "CURL not initialized!");
|
||||||
}
|
}
|
||||||
|
LOG4CXX_ERROR(logger, "Error fetching " << url);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -188,6 +188,16 @@ void SlackRTM::handleRTMStart(HTTPRequest *req, bool ok, rapidjson::Document &re
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STORE_STRING_OPTIONAL(resp, error);
|
||||||
|
if (!error.empty()) {
|
||||||
|
if (error == "account_inactive") {
|
||||||
|
LOG4CXX_INFO(logger, "Account inactive, will not try connecting again");
|
||||||
|
m_pingTimer->stop();
|
||||||
|
m_client->disconnectServer();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rapidjson::Value &url = resp["url"];
|
rapidjson::Value &url = resp["url"];
|
||||||
if (!url.IsString()) {
|
if (!url.IsString()) {
|
||||||
LOG4CXX_ERROR(logger, "No 'url' object in the reply.");
|
LOG4CXX_ERROR(logger, "No 'url' object in the reply.");
|
||||||
|
|
Loading…
Add table
Reference in a new issue