diff --git a/CMakeLists.txt b/CMakeLists.txt index a5f1d26..33b6065 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.7) project (mastodon-cpp - VERSION 0.4.0 + VERSION 0.4.1 LANGUAGES CXX ) diff --git a/README.md b/README.md index 2a3281b..943ad82 100644 --- a/README.md +++ b/README.md @@ -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 | diff --git a/src/http_sync.cpp b/src/http_sync.cpp index 1565f20..2c886c7 100644 --- a/src/http_sync.cpp +++ b/src/http_sync.cpp @@ -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 diff --git a/src/mastodon-cpp.hpp b/src/mastodon-cpp.hpp index ab8cdf8..2e9a82d 100644 --- a/src/mastodon-cpp.hpp +++ b/src/mastodon-cpp.hpp @@ -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 | */