diff --git a/src/blackmisc/statusexception.cpp b/src/blackmisc/statusexception.cpp index 81aa69040..f2e88b954 100644 --- a/src/blackmisc/statusexception.cpp +++ b/src/blackmisc/statusexception.cpp @@ -30,4 +30,9 @@ namespace BlackMisc if (m_temp.isNull()) { m_temp = m_payload.getMessage().toLocal8Bit(); } return m_temp; } + + void CStatusException::maybeThrow(const CStatusMessage &message) + { + if (!message.isEmpty()) { throw CStatusException(message); } + } } // ns diff --git a/src/blackmisc/statusexception.h b/src/blackmisc/statusexception.h index 228ab1a7b..d079b7638 100644 --- a/src/blackmisc/statusexception.h +++ b/src/blackmisc/statusexception.h @@ -22,8 +22,6 @@ namespace BlackMisc { /*! * Throwable exception class containing a CStatusMessage. - * - * This is the exception type which may be thrown by CStatusMessage::maybeThrow(). */ class BLACKMISC_EXPORT CStatusException : public std::exception { @@ -46,6 +44,9 @@ namespace BlackMisc //! Destructor. ~CStatusException() override {} + //! If the message is not empty then throw it. + static void maybeThrow(const CStatusMessage &); + private: const CStatusMessage m_payload; mutable QByteArray m_temp; diff --git a/src/blackmisc/statusmessage.cpp b/src/blackmisc/statusmessage.cpp index b18f0ce66..02ba03694 100644 --- a/src/blackmisc/statusmessage.cpp +++ b/src/blackmisc/statusmessage.cpp @@ -7,7 +7,6 @@ */ #include "blackmisc/statusmessage.h" -#include "blackmisc/statusexception.h" #include "blackmisc/propertyindexref.h" #include "blackmisc/iconlist.h" #include "blackmisc/logpattern.h" @@ -192,19 +191,6 @@ namespace BlackMisc } } - CStatusException CStatusMessage::asException() const - { - return CStatusException(*this); - } - - void CStatusMessage::maybeThrow() const - { - if (! this->isEmpty()) - { - throw this->asException(); - } - } - QString CStatusMessage::getCategoriesAsString() const { return m_categories.toQString(); diff --git a/src/blackmisc/statusmessage.h b/src/blackmisc/statusmessage.h index 821d5c8fe..b90bc7696 100644 --- a/src/blackmisc/statusmessage.h +++ b/src/blackmisc/statusmessage.h @@ -25,8 +25,6 @@ namespace BlackMisc { - class CStatusException; - namespace Private { //! Like QString::arg() but for QStringView. @@ -376,12 +374,6 @@ namespace BlackMisc //! \sa QtMessageHandler void toQtLogTriple(QtMsgType *o_type, QString *o_category, QString *o_message) const; - //! Return a throwable exception object containing this status message. - CStatusException asException() const; - - //! If message is empty then do nothing, otherwise throw a CStatusException. - void maybeThrow() const; - //! Message categories const CLogCategoryList &getCategories() const { return this->m_categories; }