Fixed bug where some error codes were not returned, added error code 11

This commit is contained in:
tastytea 2018-02-27 01:55:03 +01:00
parent 8c08af5302
commit 805384ca0b
Signed by: tastytea
GPG Key ID: 59346E0EA35C67E5
4 changed files with 14 additions and 5 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.7)
project (mastodon-cpp
VERSION 0.4.0
VERSION 0.4.1
LANGUAGES CXX
)

View File

@ -6,7 +6,7 @@ All versions below 1.0.0 (SOVERSION 0) are considered unstable and can change an
## Dependencies
* Tested OS: Linux
* Tested OS: GNU/Linux, Termux/Android
* C++ compiler (tested: gcc 6.4, clang 5.0)
* [cmake](https://cmake.org/) (tested: 3.9.6)
* [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) |
| 4 | Aborted by user |
| 10 | Failed to connect |
| 11 | Couldn't resolve host |
| 100 - 999 | HTTP status codes |
| 65535 | Unknown error |

View File

@ -62,7 +62,7 @@ const std::uint16_t API::http::request_sync(const method &meth,
{
using namespace std::placeholders; // _1, _2, _3
std::uint16_t ret;
std::uint16_t ret = 0;
ttdebug << "Path is: " << path << '\n';
try
@ -142,10 +142,15 @@ const std::uint16_t API::http::request_sync(const method &meth,
return 4;
}
else if (std::strncmp(e.what(),
"Failed to connect to", 20) == 0)
"Failed to connect to", 20) == 0)
{
ret = 10;
}
else if (std::strncmp(e.what(),
"Couldn't resolve host", 21) == 0)
{
ret = 11;
}
else
{
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 0;
return ret;
}
const void API::http::get_headers(string &headers) const

View File

@ -48,6 +48,9 @@ namespace Mastodon
* | 1 | Invalid call |
* | 2 | Not implemented |
* | 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 |
* | 65535 | Unknown exception |
*/