From 531f206850224bf416a4d9854db18caa9c7b33aa Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 20 Dec 2021 21:45:21 +0100 Subject: Tidy up NetworkError. --- src/lib/emailer.cc | 2 +- src/lib/exceptions.cc | 4 ++-- src/lib/exceptions.h | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/lib') diff --git a/src/lib/emailer.cc b/src/lib/emailer.cc index 7bed7ef97..f5812f0c2 100644 --- a/src/lib/emailer.cc +++ b/src/lib/emailer.cc @@ -231,7 +231,7 @@ Emailer::send (string server, int port, EmailProtocol protocol, string user, str auto const r = curl_easy_perform (curl); if (r != CURLE_OK) { - throw NetworkError (_("Failed to send email"), curl_easy_strerror(r)); + throw NetworkError (_("Failed to send email"), string(curl_easy_strerror(r))); } curl_slist_free_all (recipients); diff --git a/src/lib/exceptions.cc b/src/lib/exceptions.cc index 7e98a2b57..66db9fda7 100644 --- a/src/lib/exceptions.cc +++ b/src/lib/exceptions.cc @@ -116,8 +116,8 @@ KDMAsContentError::KDMAsContentError () } -NetworkError::NetworkError (string s, string d) - : runtime_error (String::compose("%1 (%2)", s, d)) +NetworkError::NetworkError (string s, optional d) + : runtime_error (String::compose("%1%2", s, d ? String::compose(" (%1)", *d) : "")) , _summary (s) , _detail (d) { diff --git a/src/lib/exceptions.h b/src/lib/exceptions.h index a8f095c22..2cae86acc 100644 --- a/src/lib/exceptions.h +++ b/src/lib/exceptions.h @@ -253,19 +253,19 @@ public: class NetworkError : public std::runtime_error { public: - explicit NetworkError (std::string s, std::string d = ""); + explicit NetworkError (std::string s, boost::optional d = boost::optional()); std::string summary () const { return _summary; } - std::string detail () const { + boost::optional detail () const { return _detail; } private: std::string _summary; - std::string _detail; + boost::optional _detail; }; -- cgit v1.2.3