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