From 89547a4110fcee9081a22ae206bd4367e736688c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 13 Dec 2021 01:00:37 +0100 Subject: Extend NetworkError to take a detail parameter. --- src/lib/exceptions.cc | 9 +++++++++ src/lib/exceptions.h | 16 +++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/lib/exceptions.cc b/src/lib/exceptions.cc index 3f87a2ebe..7e98a2b57 100644 --- a/src/lib/exceptions.cc +++ b/src/lib/exceptions.cc @@ -116,6 +116,15 @@ KDMAsContentError::KDMAsContentError () } +NetworkError::NetworkError (string s, string d) + : runtime_error (String::compose("%1 (%2)", s, d)) + , _summary (s) + , _detail (d) +{ + +} + + KDMError::KDMError (string s, string d) : runtime_error (String::compose("%1 (%2)", s, d)) , _summary (s) diff --git a/src/lib/exceptions.h b/src/lib/exceptions.h index 9b7837a46..a8f095c22 100644 --- a/src/lib/exceptions.h +++ b/src/lib/exceptions.h @@ -253,9 +253,19 @@ public: class NetworkError : public std::runtime_error { public: - explicit NetworkError (std::string s) - : std::runtime_error (s) - {} + explicit NetworkError (std::string s, std::string d = ""); + + std::string summary () const { + return _summary; + } + + std::string detail () const { + return _detail; + } + +private: + std::string _summary; + std::string _detail; }; -- cgit v1.2.3