Refactoring exceptions.
--HG-- branch : develop
This commit is contained in:
parent
345b0e5c7f
commit
31ee872a1d
|
@ -42,10 +42,10 @@
|
|||
* @brief VException constructor exception
|
||||
* @param what string with error
|
||||
*/
|
||||
VException::VException(const QString &what) V_NOEXCEPT_EXPR (true)
|
||||
:QException(), what(what), moreInfo(QString())
|
||||
VException::VException(const QString &error)
|
||||
:QException(), error(error), moreInfo(QString())
|
||||
{
|
||||
Q_ASSERT_X(not what.isEmpty(), Q_FUNC_INFO, "Error message is empty");
|
||||
Q_ASSERT_X(not error.isEmpty(), Q_FUNC_INFO, "Error message is empty");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -53,7 +53,7 @@ VException::VException(const QString &what) V_NOEXCEPT_EXPR (true)
|
|||
* @brief VException copy constructor
|
||||
* @param e exception
|
||||
*/
|
||||
VException::VException(const VException &e):what(e.What()), moreInfo(e.MoreInformation())
|
||||
VException::VException(const VException &e):error(e.WhatUtf8()), moreInfo(e.MoreInformation())
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -63,7 +63,7 @@ VException &VException::operator=(const VException &e)
|
|||
{
|
||||
return *this;
|
||||
}
|
||||
this->what = e.What();
|
||||
this->error = e.WhatUtf8();
|
||||
this->moreInfo = e.MoreInformation();
|
||||
return *this;
|
||||
}
|
||||
|
@ -75,8 +75,7 @@ VException &VException::operator=(const VException &e)
|
|||
*/
|
||||
QString VException::ErrorMessage() const
|
||||
{
|
||||
QString error = QString("Exception: %1").arg(what);
|
||||
return error;
|
||||
return QString("Exception: %1").arg(error);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -137,9 +136,15 @@ Q_NORETURN void VException::raise() const
|
|||
throw *this;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
const char* VException::what() const V_NOEXCEPT_EXPR (true)
|
||||
{
|
||||
return error.toUtf8().constData();
|
||||
}
|
||||
|
||||
//-----------------------------------------VExceptionToolWasDeleted----------------------------------------------------
|
||||
VExceptionToolWasDeleted::VExceptionToolWasDeleted(const QString &what) V_NOEXCEPT_EXPR (true)
|
||||
:VException(what)
|
||||
VExceptionToolWasDeleted::VExceptionToolWasDeleted(const QString &error)
|
||||
:VException(error)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ class VException : public QException
|
|||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(VException)
|
||||
public:
|
||||
explicit VException(const QString &what) V_NOEXCEPT_EXPR (true);
|
||||
explicit VException(const QString &error);
|
||||
VException(const VException &e);
|
||||
VException &operator=(const VException &e);
|
||||
virtual ~VException() V_NOEXCEPT_EXPR (true) Q_DECL_OVERRIDE {}
|
||||
|
@ -51,12 +51,14 @@ public:
|
|||
virtual VException *clone() const Q_DECL_OVERRIDE;
|
||||
virtual QString ErrorMessage() const;
|
||||
virtual QString DetailedInformation() const;
|
||||
QString What() const;
|
||||
QString WhatUtf8() const V_NOEXCEPT_EXPR (true);
|
||||
void AddMoreInformation(const QString &info);
|
||||
QString MoreInformation() const;
|
||||
virtual const char* what() const V_NOEXCEPT_EXPR (true);
|
||||
|
||||
protected:
|
||||
/** @brief what string with error */
|
||||
QString what;
|
||||
/** @brief error string with error */
|
||||
QString error;
|
||||
|
||||
/** @brief moreInfo more information about error */
|
||||
QString moreInfo;
|
||||
|
@ -69,9 +71,9 @@ protected:
|
|||
* @brief What return string with error
|
||||
* @return string with error
|
||||
*/
|
||||
inline QString VException::What() const
|
||||
inline QString VException::WhatUtf8() const V_NOEXCEPT_EXPR (true)
|
||||
{
|
||||
return what;
|
||||
return error;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -89,7 +91,7 @@ class VExceptionToolWasDeleted : public VException
|
|||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(VExceptionToolDeleted)
|
||||
public:
|
||||
explicit VExceptionToolWasDeleted(const QString &what) V_NOEXCEPT_EXPR (true);
|
||||
explicit VExceptionToolWasDeleted(const QString &error);
|
||||
VExceptionToolWasDeleted(const VExceptionToolWasDeleted &e);
|
||||
VExceptionToolWasDeleted &operator=(const VExceptionToolWasDeleted &e);
|
||||
virtual ~VExceptionToolWasDeleted() V_NOEXCEPT_EXPR (true) Q_DECL_OVERRIDE {}
|
||||
|
|
|
@ -31,20 +31,20 @@
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VExceptionBadId exception bad id
|
||||
* @param what string with error
|
||||
* @param error string with error
|
||||
* @param id id
|
||||
*/
|
||||
VExceptionBadId::VExceptionBadId(const QString &what, const quint32 &id)
|
||||
:VException(what), id(id), key(QString()){}
|
||||
VExceptionBadId::VExceptionBadId(const QString &error, const quint32 &id)
|
||||
:VException(error), id(id), key(QString()){}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VExceptionBadId exception bad id
|
||||
* @param what string with error
|
||||
* @param error string with error
|
||||
* @param key string key
|
||||
*/
|
||||
VExceptionBadId::VExceptionBadId(const QString &what, const QString &key)
|
||||
:VException(what), id(NULL_ID), key(key){}
|
||||
VExceptionBadId::VExceptionBadId(const QString &error, const QString &key)
|
||||
:VException(error), id(NULL_ID), key(key){}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
@ -77,11 +77,11 @@ QString VExceptionBadId::ErrorMessage() const
|
|||
QString error;
|
||||
if (key.isEmpty())
|
||||
{
|
||||
error = QString("ExceptionBadId: %1, id = %2").arg(what).arg(id);
|
||||
error = QString("ExceptionBadId: %1, id = %2").arg(error).arg(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
error = QString("ExceptionBadId: %1, id = %2").arg(what).arg(key);
|
||||
error = QString("ExceptionBadId: %1, id = %2").arg(error).arg(key);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
|
|
@ -37,8 +37,8 @@
|
|||
class VExceptionBadId : public VException
|
||||
{
|
||||
public:
|
||||
VExceptionBadId(const QString &what, const quint32 &id);
|
||||
VExceptionBadId(const QString &what, const QString &key);
|
||||
VExceptionBadId(const QString &error, const quint32 &id);
|
||||
VExceptionBadId(const QString &error, const QString &key);
|
||||
VExceptionBadId(const VExceptionBadId &e);
|
||||
VExceptionBadId &operator=(const VExceptionBadId &e);
|
||||
virtual ~VExceptionBadId() V_NOEXCEPT_EXPR (true) Q_DECL_OVERRIDE {}
|
||||
|
|
|
@ -31,11 +31,11 @@
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VExceptionConversionError exception conversion error
|
||||
* @param what string with error
|
||||
* @param error string with error
|
||||
* @param str string, where happend error
|
||||
*/
|
||||
VExceptionConversionError::VExceptionConversionError(const QString &what, const QString &str)
|
||||
:VException(what), str(str)
|
||||
VExceptionConversionError::VExceptionConversionError(const QString &error, const QString &str)
|
||||
:VException(error), str(str)
|
||||
{
|
||||
Q_ASSERT_X(not str.isEmpty(), Q_FUNC_INFO, "Error converting string is empty");
|
||||
}
|
||||
|
@ -60,6 +60,6 @@ VExceptionConversionError::~VExceptionConversionError() V_NOEXCEPT_EXPR (true)
|
|||
*/
|
||||
QString VExceptionConversionError::ErrorMessage() const
|
||||
{
|
||||
QString error = QString("ExceptionConversionError: %1 \"%2\"").arg(what, str);
|
||||
QString error = QString("ExceptionConversionError: %1 \"%2\"").arg(error, str);
|
||||
return error;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
class VExceptionConversionError : public VException
|
||||
{
|
||||
public:
|
||||
VExceptionConversionError(const QString &what, const QString &str);
|
||||
VExceptionConversionError(const QString &error, const QString &str);
|
||||
VExceptionConversionError(const VExceptionConversionError &e);
|
||||
virtual ~VExceptionConversionError() V_NOEXCEPT_EXPR (true) Q_DECL_OVERRIDE;
|
||||
virtual QString ErrorMessage() const Q_DECL_OVERRIDE;
|
||||
|
|
|
@ -69,7 +69,7 @@ VExceptionEmptyParameter::~VExceptionEmptyParameter() V_NOEXCEPT_EXPR (true)
|
|||
*/
|
||||
QString VExceptionEmptyParameter::ErrorMessage() const
|
||||
{
|
||||
QString error = QString("ExceptionEmptyParameter: %1 %2").arg(what, name);
|
||||
QString error = QString("ExceptionEmptyParameter: %1 %2").arg(error, name);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,8 @@ class QDomElement;
|
|||
class VExceptionEmptyParameter : public VException
|
||||
{
|
||||
public:
|
||||
VExceptionEmptyParameter(const QString &what, const QString &name, const QDomElement &domElement);
|
||||
VExceptionEmptyParameter(const QString &error, const QString &name,
|
||||
const QDomElement &domElement);
|
||||
VExceptionEmptyParameter(const VExceptionEmptyParameter &e);
|
||||
virtual ~VExceptionEmptyParameter() V_NOEXCEPT_EXPR (true) Q_DECL_OVERRIDE;
|
||||
virtual QString ErrorMessage() const Q_DECL_OVERRIDE;
|
||||
|
|
|
@ -62,7 +62,7 @@ VExceptionObjectError::VExceptionObjectError(const VExceptionObjectError &e)
|
|||
*/
|
||||
QString VExceptionObjectError::ErrorMessage() const
|
||||
{
|
||||
QString error = QString("ExceptionObjectError: %1").arg(what);
|
||||
QString error = QString("ExceptionObjectError: %1").arg(error);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class QDomElement;
|
|||
class VExceptionObjectError : public VException
|
||||
{
|
||||
public:
|
||||
VExceptionObjectError(const QString &what, const QDomElement &domElement);
|
||||
VExceptionObjectError(const QString &error, const QDomElement &domElement);
|
||||
VExceptionObjectError(const VExceptionObjectError &e);
|
||||
virtual ~VExceptionObjectError() V_NOEXCEPT_EXPR (true) Q_DECL_OVERRIDE {}
|
||||
virtual QString ErrorMessage() const Q_DECL_OVERRIDE;
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
class VExceptionUndo : public VException
|
||||
{
|
||||
public:
|
||||
explicit VExceptionUndo(const QString &what);
|
||||
explicit VExceptionUndo(const QString &error);
|
||||
VExceptionUndo(const VExceptionUndo &e);
|
||||
virtual ~VExceptionUndo() V_NOEXCEPT_EXPR (true) Q_DECL_OVERRIDE;
|
||||
};
|
||||
|
|
|
@ -62,7 +62,7 @@ VExceptionWrongId::VExceptionWrongId(const VExceptionWrongId &e)
|
|||
*/
|
||||
QString VExceptionWrongId::ErrorMessage() const
|
||||
{
|
||||
QString error = QString("ExceptionWrongId: %1").arg(what);
|
||||
QString error = QString("ExceptionWrongId: %1").arg(error);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class QDomElement;
|
|||
class VExceptionWrongId : public VException
|
||||
{
|
||||
public:
|
||||
VExceptionWrongId(const QString &what, const QDomElement &domElement);
|
||||
VExceptionWrongId(const QString &error, const QDomElement &domElement);
|
||||
VExceptionWrongId(const VExceptionWrongId &e);
|
||||
virtual ~VExceptionWrongId() V_NOEXCEPT_EXPR (true) Q_DECL_OVERRIDE {}
|
||||
virtual QString ErrorMessage() const Q_DECL_OVERRIDE;
|
||||
|
|
|
@ -55,7 +55,7 @@ static const quint32 null_id = 0;
|
|||
# define V_NOEXCEPT_EXPR(x) noexcept(x) // GCC 4.7 and following have noexcept
|
||||
# endif
|
||||
# elif defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 180021114
|
||||
# define QMUP_NOEXCEPT_EXPR(x) noexcept(x)
|
||||
# define V_NOEXCEPT_EXPR(x) noexcept(x)
|
||||
# else
|
||||
# define V_NOEXCEPT_EXPR(x)
|
||||
# endif
|
||||
|
|
Loading…
Reference in New Issue
Block a user