From c60f7a379d731d8e22b45029e446f5958f9b62c8 Mon Sep 17 00:00:00 2001 From: tastytea Date: Thu, 16 Jan 2020 22:37:53 +0100 Subject: [PATCH] Replaced MastodonException and replaced it with CURLException. --- src/config.cpp | 2 +- src/exceptions.cpp | 13 +------------ src/exceptions.hpp | 11 ----------- src/main.cpp | 5 ----- src/mastoapi.cpp | 2 +- 5 files changed, 3 insertions(+), 30 deletions(-) diff --git a/src/config.cpp b/src/config.cpp index 769779b..3b79f59 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -214,7 +214,7 @@ string Config::get_access_token(const string &instance) const } } - throw MastodonException{ret.curl_error_code}; + throw CURLException{ret.curl_error_code}; } void Config::parse() diff --git a/src/exceptions.cpp b/src/exceptions.cpp index 93bb290..a6546c3 100644 --- a/src/exceptions.cpp +++ b/src/exceptions.cpp @@ -40,18 +40,7 @@ CURLException::CURLException(const int error) const char *CURLException::what() const noexcept { - static const string error_string{"libCURL error: " + to_string(error_code)}; - return error_string.c_str(); -} - -MastodonException::MastodonException(const int error) - : error_code{static_cast(error)} -{} - -const char *MastodonException::what() const noexcept -{ - static const string error_string{"Mastodon error: " - + to_string(error_code)}; + static const string error_string{"libcurl error: " + to_string(error_code)}; return error_string.c_str(); } diff --git a/src/exceptions.hpp b/src/exceptions.hpp index f672790..3000f6a 100644 --- a/src/exceptions.hpp +++ b/src/exceptions.hpp @@ -49,17 +49,6 @@ public: const char *what() const noexcept override; }; -class MastodonException : public exception -{ -public: - const uint16_t error_code; - - explicit MastodonException(int error); - - [[nodiscard]] - const char *what() const noexcept override; -}; - class FileException : public exception { public: diff --git a/src/main.cpp b/src/main.cpp index 68d8211..97402ad 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -122,11 +122,6 @@ int main(int argc, char *argv[]) cerr << e.what() << '\n'; return error::file; } - catch (const MastodonException &e) - { - cerr << e.what() << '\n'; - return error::mastodon; - } catch (const HTTPException &e) { cerr << e.what() << '\n'; diff --git a/src/mastoapi.cpp b/src/mastoapi.cpp index e26112a..5a39fd6 100644 --- a/src/mastoapi.cpp +++ b/src/mastoapi.cpp @@ -114,7 +114,7 @@ void MastoAPI::post_item(const Item &item) { throw HTTPException{ret.http_status}; } - throw MastodonException{ret.curl_error_code}; + throw CURLException{ret.curl_error_code}; } BOOST_LOG_TRIVIAL(debug) << "Posted status with GUID: " << item.guid;