1
0

feat(GODT-2364): added optional details to C++ exceptions.

This commit is contained in:
Xavier Michelon
2023-02-15 15:55:23 +01:00
committed by Jakub
parent 10cf153678
commit 9ad5f74409
12 changed files with 75 additions and 48 deletions

View File

@ -23,11 +23,13 @@ namespace bridgepp {
//****************************************************************************************************************************************************
/// \param[in] what A description of the exception
/// \param[in] what A description of the exception.
/// \param[in] details The optional details for the exception.
//****************************************************************************************************************************************************
Exception::Exception(QString what) noexcept
Exception::Exception(QString what, QString details) noexcept
: std::exception()
, what_(std::move(what)) {
, what_(std::move(what))
, details_(std::move(details)) {
}
@ -36,7 +38,8 @@ Exception::Exception(QString what) noexcept
//****************************************************************************************************************************************************
Exception::Exception(Exception const &ref) noexcept
: std::exception(ref)
, what_(ref.what_) {
, what_(ref.what_)
, details_(ref.details_) {
}
@ -45,14 +48,15 @@ Exception::Exception(Exception const &ref) noexcept
//****************************************************************************************************************************************************
Exception::Exception(Exception &&ref) noexcept
: std::exception(ref)
, what_(ref.what_) {
, what_(ref.what_)
, details_(ref.details_) {
}
//****************************************************************************************************************************************************
/// \return a string describing the exception
//****************************************************************************************************************************************************
QString const &Exception::qwhat() const noexcept {
QString Exception::qwhat() const noexcept {
return what_;
}
@ -65,4 +69,12 @@ const char *Exception::what() const noexcept {
}
//****************************************************************************************************************************************************
/// \return The details for the exception.
//****************************************************************************************************************************************************
QString Exception::details() const noexcept {
return details_;
}
} // namespace bridgepp

View File

@ -31,17 +31,19 @@ namespace bridgepp {
//****************************************************************************************************************************************************
class Exception : public std::exception {
public: // member functions
explicit Exception(QString what = QString()) noexcept; ///< Constructor
explicit Exception(QString what = QString(), QString details = QString()) noexcept; ///< Constructor
Exception(Exception const &ref) noexcept; ///< copy constructor
Exception(Exception &&ref) noexcept; ///< copy constructor
Exception &operator=(Exception const &) = delete; ///< Disabled assignment operator
Exception &operator=(Exception &&) = delete; ///< Disabled assignment operator
~Exception() noexcept override = default; ///< Destructor
QString const &qwhat() const noexcept; ///< Return the description of the exception as a QString
QString qwhat() const noexcept; ///< Return the description of the exception as a QString
const char *what() const noexcept override; ///< Return the description of the exception as C style string
QString details() const noexcept; ///< Return the details for the exception
private: // data members
QString const what_; ///< The description of the exception
QString const what_; ///< The description of the exception.
QString const details_; ///< The optional details for the exception.
};