Fixed bug where some error codes were not returned, added error code 11
This commit is contained in:
parent
8c08af5302
commit
805384ca0b
|
@ -1,6 +1,6 @@
|
||||||
cmake_minimum_required (VERSION 3.7)
|
cmake_minimum_required (VERSION 3.7)
|
||||||
project (mastodon-cpp
|
project (mastodon-cpp
|
||||||
VERSION 0.4.0
|
VERSION 0.4.1
|
||||||
LANGUAGES CXX
|
LANGUAGES CXX
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ All versions below 1.0.0 (SOVERSION 0) are considered unstable and can change an
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
* Tested OS: Linux
|
* Tested OS: GNU/Linux, Termux/Android
|
||||||
* C++ compiler (tested: gcc 6.4, clang 5.0)
|
* C++ compiler (tested: gcc 6.4, clang 5.0)
|
||||||
* [cmake](https://cmake.org/) (tested: 3.9.6)
|
* [cmake](https://cmake.org/) (tested: 3.9.6)
|
||||||
* [libcurl](https://curl.haxx.se/) (tested: 7.58.0)
|
* [libcurl](https://curl.haxx.se/) (tested: 7.58.0)
|
||||||
|
@ -77,6 +77,7 @@ After you did a `make install`, a project consisting of one file can be compiled
|
||||||
| 3 | URL changed (HTTP 301 or 308) |
|
| 3 | URL changed (HTTP 301 or 308) |
|
||||||
| 4 | Aborted by user |
|
| 4 | Aborted by user |
|
||||||
| 10 | Failed to connect |
|
| 10 | Failed to connect |
|
||||||
|
| 11 | Couldn't resolve host |
|
||||||
| 100 - 999 | HTTP status codes |
|
| 100 - 999 | HTTP status codes |
|
||||||
| 65535 | Unknown error |
|
| 65535 | Unknown error |
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ const std::uint16_t API::http::request_sync(const method &meth,
|
||||||
{
|
{
|
||||||
using namespace std::placeholders; // _1, _2, _3
|
using namespace std::placeholders; // _1, _2, _3
|
||||||
|
|
||||||
std::uint16_t ret;
|
std::uint16_t ret = 0;
|
||||||
ttdebug << "Path is: " << path << '\n';
|
ttdebug << "Path is: " << path << '\n';
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -142,10 +142,15 @@ const std::uint16_t API::http::request_sync(const method &meth,
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
else if (std::strncmp(e.what(),
|
else if (std::strncmp(e.what(),
|
||||||
"Failed to connect to", 20) == 0)
|
"Failed to connect to", 20) == 0)
|
||||||
{
|
{
|
||||||
ret = 10;
|
ret = 10;
|
||||||
}
|
}
|
||||||
|
else if (std::strncmp(e.what(),
|
||||||
|
"Couldn't resolve host", 21) == 0)
|
||||||
|
{
|
||||||
|
ret = 11;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cerr << "RUNTIME ERROR: " << e.what() << std::endl;
|
cerr << "RUNTIME ERROR: " << e.what() << std::endl;
|
||||||
|
@ -161,7 +166,7 @@ const std::uint16_t API::http::request_sync(const method &meth,
|
||||||
return 0xffff;
|
return 0xffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
const void API::http::get_headers(string &headers) const
|
const void API::http::get_headers(string &headers) const
|
||||||
|
|
|
@ -48,6 +48,9 @@ namespace Mastodon
|
||||||
* | 1 | Invalid call |
|
* | 1 | Invalid call |
|
||||||
* | 2 | Not implemented |
|
* | 2 | Not implemented |
|
||||||
* | 3 | URL changed (HTTP 301 or 308) |
|
* | 3 | URL changed (HTTP 301 or 308) |
|
||||||
|
* | 4 | Aborted by user |
|
||||||
|
* | 10 | Failed to connect |
|
||||||
|
* | 11 | Couldn't resolve host |
|
||||||
* | 100 - 999 | HTTP status codes |
|
* | 100 - 999 | HTTP status codes |
|
||||||
* | 65535 | Unknown exception |
|
* | 65535 | Unknown exception |
|
||||||
*/
|
*/
|
||||||
|
|
Reference in New Issue
Block a user