Fix CURLException::what().
This commit is contained in:
parent
442f27a511
commit
e1827d08cc
|
@ -222,15 +222,19 @@ void CURLWrapper::check(const CURLcode code)
|
|||
}
|
||||
}
|
||||
|
||||
const char *CURLException::what() noexcept
|
||||
const char *CURLException::what() const noexcept
|
||||
{
|
||||
if (!_error_message.empty())
|
||||
// NOTE: The string has to be static, or it'll vanish before it can be
|
||||
// used. Couldn't find good documentation on that.
|
||||
static string error_string;
|
||||
error_string = _error_message;
|
||||
if (!error_string.empty())
|
||||
{
|
||||
_error_message = ": " + _error_message;
|
||||
error_string = " – " + error_string;
|
||||
}
|
||||
_error_message = "libcurl_error: " + std::to_string(error_code)
|
||||
+ _error_message;
|
||||
return _error_message.c_str();
|
||||
error_string = "libcurl error: " + std::to_string(error_code)
|
||||
+ error_string;
|
||||
return error_string.c_str();
|
||||
}
|
||||
|
||||
} // namespace curl_wrapper
|
||||
|
|
|
@ -233,7 +233,7 @@ public:
|
|||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
[[nodiscard]] const char *what() noexcept;
|
||||
[[nodiscard]] const char *what() const noexcept override;
|
||||
|
||||
private:
|
||||
string _error_message;
|
||||
|
|
Loading…
Reference in New Issue