From a7b714259bdea71a74cdb483909ca5deb5a5543e Mon Sep 17 00:00:00 2001 From: tastytea Date: Mon, 9 Apr 2018 17:55:11 +0200 Subject: [PATCH] Added errors: SSL, timeout --- CMakeLists.txt | 2 +- README.md | 2 ++ src/http.cpp | 11 +++++++++++ src/mastodon-cpp.hpp | 2 ++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c0300e..5a6008e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.7) project (mastodon-cpp - VERSION 0.8.5 + VERSION 0.8.6 LANGUAGES CXX ) diff --git a/README.md b/README.md index 673560a..59e747a 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,8 @@ mastodon-cpp will never use error codes below 11, except 0. | 21 | Couldn't resolve host | | 22 | Network is unreachable | | 23 | Transfer interrupted | +| 24 | SSL error | +| 25 | Timeout | | 100 - 999 | HTTP status codes | | 65535 | Unknown error | diff --git a/src/http.cpp b/src/http.cpp index 2aea56d..1d276d5 100644 --- a/src/http.cpp +++ b/src/http.cpp @@ -136,6 +136,7 @@ const uint_fast16_t API::http::request(const method &meth, } catch (curlpp::RuntimeError &e) { + // FIXME: There has to be a better way if (std::strncmp(e.what(), "Failed writing body", 19) == 0) { @@ -164,6 +165,16 @@ const uint_fast16_t API::http::request(const method &meth, { ret = 23; } + else if (std::strncmp(e.what(), + "OpenSSL SSL_read: SSL_ERROR_SYSCALL", 35) == 0) + { + ret = 24; + } + else if (std::strncmp(e.what(), + "Operation timed out", 19) == 0) + { + ret = 25; + } else { cerr << "RUNTIME ERROR: " << e.what() << std::endl; diff --git a/src/mastodon-cpp.hpp b/src/mastodon-cpp.hpp index 0dda7dd..d5a95f5 100644 --- a/src/mastodon-cpp.hpp +++ b/src/mastodon-cpp.hpp @@ -68,6 +68,8 @@ namespace Mastodon * | 21 | Couldn't resolve host | * | 22 | Network is unreachable | * | 23 | Transfer interrupted | + * | 24 | SSL error | + * | 25 | Timeout | * | 100 - 999 | HTTP status codes | * | 65535 | Unknown exception | */