diff --git a/include/Client_Exceptions.h b/include/Client_Exceptions.h index 8452753..db9c85d 100644 --- a/include/Client_Exceptions.h +++ b/include/Client_Exceptions.h @@ -17,13 +17,13 @@ class ClientException : public std::exception // REST Client Exceptions -class BadSetupSessionREST : public ClientException // for bad REST requests +class BadSetupSessionREST : public ClientException { public: BadSetupSessionREST(); }; -class BadRequestREST : public ClientException // for trying methods where auth is needed but keys are missing +class BadRequestREST : public ClientException { public: BadRequestREST(); diff --git a/src/REST_Client.cpp b/src/REST_Client.cpp index cb639be..e45a6e3 100644 --- a/src/REST_Client.cpp +++ b/src/REST_Client.cpp @@ -63,7 +63,7 @@ RestSession::RestSession() // except handles in rest_init exchange client level curl_easy_setopt(this->_get_handle, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(this->_get_handle, CURLOPT_WRITEFUNCTION, _REQ_CALLBACK); curl_easy_setopt(this->_get_handle, CURLOPT_FAILONERROR, 0); - + if (!(this->_get_handle)) throw("BAD_GET_SETUP"); _post_handle = curl_easy_init(); curl_easy_setopt(this->_post_handle, CURLOPT_POST, 1L); @@ -71,6 +71,7 @@ RestSession::RestSession() // except handles in rest_init exchange client level curl_easy_setopt(this->_post_handle, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(this->_post_handle, CURLOPT_WRITEFUNCTION, _REQ_CALLBACK); curl_easy_setopt(this->_post_handle, CURLOPT_FAILONERROR, 0); + if (!(this->_post_handle)) throw("BAD_POST_SETUP"); // handle exc _put_handle = curl_easy_init(); curl_easy_setopt(this->_put_handle, CURLOPT_UPLOAD, 1L); @@ -78,6 +79,7 @@ RestSession::RestSession() // except handles in rest_init exchange client level curl_easy_setopt(this->_put_handle, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(this->_put_handle, CURLOPT_WRITEFUNCTION, _REQ_CALLBACK); curl_easy_setopt(this->_put_handle, CURLOPT_FAILONERROR, 0); + if (!(this->_put_handle)) throw("BAD_PUT_SETUP"); // handle exc _delete_handle = curl_easy_init(); curl_easy_setopt(this->_delete_handle, CURLOPT_CUSTOMREQUEST, "DELETE"); @@ -85,13 +87,7 @@ RestSession::RestSession() // except handles in rest_init exchange client level curl_easy_setopt(this->_delete_handle, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(this->_delete_handle, CURLOPT_WRITEFUNCTION, _REQ_CALLBACK); curl_easy_setopt(this->_delete_handle, CURLOPT_FAILONERROR, 0); - - - if (!(this->_get_handle)) throw("exc"); // handle exc - if (!(this->_post_handle)) throw("exc"); // handle exc - if (!(this->_put_handle)) throw("exc"); // handle exc - if (!(this->_delete_handle)) throw("exc"); // handle exc - + if (!(this->_delete_handle)) throw("BAD_DELETE_SETUP"); // handle exc this->status = 1; }