diff options
author | tastytea | 2020-01-10 12:18:04 +0100 |
---|---|---|
committer | tastytea | 2020-01-10 12:22:00 +0100 |
commit | 1263b03999bb0f6f38f725cf25b33c6da96e0053 (patch) | |
tree | d7e1e451703442cd9900cfbcfb1a98437e175098 | |
parent | a9e918ba6af8bbff427838d56968c66d82327214 (diff) | |
download | mastodonpp-1263b03999bb0f6f38f725cf25b33c6da96e0053.tar mastodonpp-1263b03999bb0f6f38f725cf25b33c6da96e0053.tar.gz mastodonpp-1263b03999bb0f6f38f725cf25b33c6da96e0053.zip |
Add a message only constructor to CURLException.
-rw-r--r-- | include/exceptions.hpp | 7 | ||||
-rw-r--r-- | src/exceptions.cpp | 13 |
2 files changed, 18 insertions, 2 deletions
diff --git a/include/exceptions.hpp b/include/exceptions.hpp index 9e51d97..5cbad42 100644 --- a/include/exceptions.hpp +++ b/include/exceptions.hpp @@ -56,6 +56,13 @@ public: string error_buffer); /*! + * @brief Constructor with message. + * + * @since 0.1.0 + */ + explicit CURLException(string message); + + /*! * @brief The error code returned by libcurl. * * For more information consult diff --git a/src/exceptions.cpp b/src/exceptions.cpp index 7dd0e0f..f4630a4 100644 --- a/src/exceptions.cpp +++ b/src/exceptions.cpp @@ -36,10 +36,19 @@ CURLException::CURLException(const CURLcode &error, string message, , _error_buffer{move(error_buffer)} {} +CURLException::CURLException(string message) + : error_code{CURLE_OK} + , _message{move(message)} +{} + const char *CURLException::what() const noexcept { - static string error_string{"libCURL error: " + to_string(error_code) - + " - " + _message}; + static string error_string{"libCURL error: "}; + if (error_code != CURLE_OK) + { + error_string += to_string(error_code) + " - "; + } + error_string += _message; if (!_error_buffer.empty()) { error_string += " [" + _error_buffer + "]"; |