Refactoring.

--HG--
branch : develop
This commit is contained in:
dismine 2013-10-26 22:30:20 +03:00
parent b42bc9560a
commit 2a88e74086
14 changed files with 75 additions and 113 deletions

View File

@ -25,9 +25,6 @@ VException::VException(const QString &what):QException(), what(what){
Q_ASSERT_X(!what.isEmpty(), Q_FUNC_INFO, "Error message is empty"); Q_ASSERT_X(!what.isEmpty(), Q_FUNC_INFO, "Error message is empty");
} }
VException::VException(const VException &e):what(e.What()){
}
QString VException::ErrorMessage() const{ QString VException::ErrorMessage() const{
QString error = QString("Exception: %1").arg(what); QString error = QString("Exception: %1").arg(what);
return error; return error;

View File

@ -24,21 +24,19 @@
#define VEXCEPTION_H #define VEXCEPTION_H
#include <QException> #include <QException>
#include <QString>
class VException : public QException class VException : public QException{
{
public: public:
VException(const QString &what); VException(const QString &what);
VException(const VException &e); VException(const VException &e):what(e.What()){}
virtual ~VException() noexcept(true){} virtual ~VException() noexcept(true){}
void raise() const { throw *this; } inline void raise() const { throw *this; }
VException *clone() const { return new VException(*this); } inline VException *clone() const { return new VException(*this); }
virtual QString ErrorMessage() const; virtual QString ErrorMessage() const;
virtual QString DetailedInformation() const { return QString(); } virtual QString DetailedInformation() const { return QString(); }
QString What() const {return what;} inline QString What() const {return what;}
protected: protected:
QString what; QString what;
}; };
#endif // VEXCEPTION_H #endif // VEXCEPTION_H

View File

@ -21,17 +21,6 @@
#include "vexceptionbadid.h" #include "vexceptionbadid.h"
VExceptionBadId::VExceptionBadId(const QString &what, const qint64 &id):VException(what), id(id),
key(QString()){
}
VExceptionBadId::VExceptionBadId(const QString &what, const QString &key):VException(what), id(0), key(key)
{
}
VExceptionBadId::VExceptionBadId(const VExceptionBadId &e):VException(e), id(e.BadId()), key(e.BadKey()){
}
QString VExceptionBadId::ErrorMessage() const{ QString VExceptionBadId::ErrorMessage() const{
QString error; QString error;
if(key.isEmpty()){ if(key.isEmpty()){

View File

@ -24,19 +24,19 @@
#include "vexception.h" #include "vexception.h"
class VExceptionBadId : public VException class VExceptionBadId : public VException{
{
public: public:
VExceptionBadId(const QString &what, const qint64 &id); VExceptionBadId(const QString &what, const qint64 &id):VException(what), id(id),
VExceptionBadId(const QString &what, const QString &key); key(QString()){}
VExceptionBadId(const VExceptionBadId &e); VExceptionBadId(const QString &what, const QString &key):VException(what), id(0), key(key){}
virtual ~VExceptionBadId() noexcept(true){} VExceptionBadId(const VExceptionBadId &e):VException(e), id(e.BadId()), key(e.BadKey()){}
virtual ~VExceptionBadId() noexcept(true){}
virtual QString ErrorMessage() const; virtual QString ErrorMessage() const;
qint64 BadId() const {return id; } inline qint64 BadId() const {return id; }
QString BadKey() const {return key; } inline QString BadKey() const {return key; }
protected: protected:
qint64 id; qint64 id;
QString key; QString key;
}; };
#endif // VEXCEPTIONBADID_H #endif // VEXCEPTIONBADID_H

View File

@ -26,10 +26,6 @@ VExceptionConversionError::VExceptionConversionError(const QString &what, const
Q_ASSERT_X(!str.isEmpty(), Q_FUNC_INFO, "Error converting string is empty"); Q_ASSERT_X(!str.isEmpty(), Q_FUNC_INFO, "Error converting string is empty");
} }
VExceptionConversionError::VExceptionConversionError(const VExceptionConversionError &e):
VException(e), str(e.String()){
}
QString VExceptionConversionError::ErrorMessage() const{ QString VExceptionConversionError::ErrorMessage() const{
QString error = QString("ExceptionConversionError: %1 %2").arg(what, str); QString error = QString("ExceptionConversionError: %1 %2").arg(what, str);
return error; return error;

View File

@ -24,16 +24,15 @@
#include "vexception.h" #include "vexception.h"
class VExceptionConversionError : public VException class VExceptionConversionError : public VException{
{
public: public:
VExceptionConversionError(const QString &what, const QString &str); VExceptionConversionError(const QString &what, const QString &str);
VExceptionConversionError(const VExceptionConversionError &e); VExceptionConversionError(const VExceptionConversionError &e):VException(e), str(e.String()){}
virtual ~VExceptionConversionError() noexcept(true) {} virtual ~VExceptionConversionError() noexcept(true) {}
virtual QString ErrorMessage() const; virtual QString ErrorMessage() const;
QString String() const {return str;} inline QString String() const {return str;}
protected: protected:
QString str; QString str;
}; };
#endif // VEXCEPTIONCONVERSIONERROR_H #endif // VEXCEPTIONCONVERSIONERROR_H

View File

@ -20,7 +20,6 @@
****************************************************************************/ ****************************************************************************/
#include "vexceptionemptyparameter.h" #include "vexceptionemptyparameter.h"
#include <QDebug>
VExceptionEmptyParameter::VExceptionEmptyParameter(const QString &what, const QString &name, VExceptionEmptyParameter::VExceptionEmptyParameter(const QString &what, const QString &name,
const QDomElement &domElement): VException(what), const QDomElement &domElement): VException(what),
@ -33,10 +32,6 @@ VExceptionEmptyParameter::VExceptionEmptyParameter(const QString &what, const QS
lineNumber = domElement.lineNumber(); lineNumber = domElement.lineNumber();
} }
VExceptionEmptyParameter::VExceptionEmptyParameter(const VExceptionEmptyParameter &e):VException(e),
name(e.Name()), tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.LineNumber()){
}
QString VExceptionEmptyParameter::ErrorMessage() const{ QString VExceptionEmptyParameter::ErrorMessage() const{
QString error = QString("ExceptionEmptyParameter: %1 %2").arg(what, name); QString error = QString("ExceptionEmptyParameter: %1 %2").arg(what, name);
return error; return error;

View File

@ -23,25 +23,25 @@
#define VEXCEPTIONEMPTYPARAMETER_H #define VEXCEPTIONEMPTYPARAMETER_H
#include "vexception.h" #include "vexception.h"
#include <QDomElement>
class VExceptionEmptyParameter : public VException class VExceptionEmptyParameter : public VException{
{
public: public:
VExceptionEmptyParameter(const QString &what, const QString &name, const QDomElement &domElement); VExceptionEmptyParameter(const QString &what, const QString &name,
VExceptionEmptyParameter(const VExceptionEmptyParameter &e); const QDomElement &domElement);
virtual ~VExceptionEmptyParameter() noexcept(true) {} VExceptionEmptyParameter(const VExceptionEmptyParameter &e):VException(e), name(e.Name()),
tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.LineNumber()){}
virtual ~VExceptionEmptyParameter() noexcept(true) {}
virtual QString ErrorMessage() const; virtual QString ErrorMessage() const;
virtual QString DetailedInformation() const; virtual QString DetailedInformation() const;
QString Name() const {return name;} inline QString Name() const {return name;}
QString TagText() const {return tagText;} inline QString TagText() const {return tagText;}
QString TagName() const {return tagName;} inline QString TagName() const {return tagName;}
qint32 LineNumber() const {return lineNumber;} inline qint32 LineNumber() const {return lineNumber;}
protected: protected:
QString name; QString name;
QString tagText; QString tagText;
QString tagName; QString tagName;
qint32 lineNumber; qint32 lineNumber;
}; };
#endif // VEXCEPTIONEMPTYPARAMETER_H #endif // VEXCEPTIONEMPTYPARAMETER_H

View File

@ -31,10 +31,6 @@ VExceptionObjectError::VExceptionObjectError(const QString &what, const QDomElem
lineNumber = domElement.lineNumber(); lineNumber = domElement.lineNumber();
} }
VExceptionObjectError::VExceptionObjectError(const VExceptionObjectError &e):VException(e),
tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.LineNumber()), moreInfo(e.MoreInformation()){
}
QString VExceptionObjectError::ErrorMessage() const{ QString VExceptionObjectError::ErrorMessage() const{
QString error = QString("ExceptionObjectError: %1").arg(what); QString error = QString("ExceptionObjectError: %1").arg(what);
return error; return error;

View File

@ -23,26 +23,25 @@
#define VEXCEPTIONOBJECTERROR_H #define VEXCEPTIONOBJECTERROR_H
#include "vexception.h" #include "vexception.h"
#include <QDomElement>
class VExceptionObjectError : public VException class VExceptionObjectError : public VException{
{
public: public:
VExceptionObjectError(const QString &what, const QDomElement &domElement); VExceptionObjectError(const QString &what, const QDomElement &domElement);
VExceptionObjectError(const VExceptionObjectError &e); VExceptionObjectError(const VExceptionObjectError &e):VException(e), tagText(e.TagText()),
virtual ~VExceptionObjectError() noexcept(true) {} tagName(e.TagName()), lineNumber(e.LineNumber()), moreInfo(e.MoreInformation()){}
virtual ~VExceptionObjectError() noexcept(true) {}
virtual QString ErrorMessage() const; virtual QString ErrorMessage() const;
virtual QString DetailedInformation() const; virtual QString DetailedInformation() const;
QString TagText() const {return tagText;} inline QString TagText() const {return tagText;}
QString TagName() const {return tagName;} inline QString TagName() const {return tagName;}
qint32 LineNumber() const {return lineNumber;} inline qint32 LineNumber() const {return lineNumber;}
void AddMoreInformation(const QString &info); void AddMoreInformation(const QString &info);
QString MoreInformation() const {return moreInfo;} inline QString MoreInformation() const {return moreInfo;}
protected: protected:
QString tagText; QString tagText;
QString tagName; QString tagName;
qint32 lineNumber; qint32 lineNumber;
QString moreInfo; QString moreInfo;
}; };
#endif // VEXCEPTIONOBJECTERROR_H #endif // VEXCEPTIONOBJECTERROR_H

View File

@ -1,5 +1,4 @@
#include "vexceptionuniqueid.h" #include "vexceptionuniqueid.h"
#include <QTextStream>
VExceptionUniqueId::VExceptionUniqueId(const QString &what, const QDomElement &domElement) VExceptionUniqueId::VExceptionUniqueId(const QString &what, const QDomElement &domElement)
:VException(what), tagText(QString()), tagName(QString()), lineNumber(-1){ :VException(what), tagText(QString()), tagName(QString()), lineNumber(-1){

View File

@ -2,23 +2,22 @@
#define VEXCEPTIONUNIQUEID_H #define VEXCEPTIONUNIQUEID_H
#include "vexception.h" #include "vexception.h"
#include <QDomElement>
class VExceptionUniqueId : public VException{ class VExceptionUniqueId : public VException{
public: public:
VExceptionUniqueId(const QString &what, const QDomElement &domElement); VExceptionUniqueId(const QString &what, const QDomElement &domElement);
VExceptionUniqueId(const VExceptionUniqueId &e):VException(e), tagText(e.TagText()), VExceptionUniqueId(const VExceptionUniqueId &e):VException(e), tagText(e.TagText()),
tagName(e.TagName()), lineNumber(e.LineNumber()){} tagName(e.TagName()), lineNumber(e.LineNumber()){}
virtual ~VExceptionUniqueId() noexcept(true){} virtual ~VExceptionUniqueId() noexcept(true){}
virtual QString ErrorMessage() const; virtual QString ErrorMessage() const;
virtual QString DetailedInformation() const; virtual QString DetailedInformation() const;
QString TagText() const {return tagText;} inline QString TagText() const {return tagText;}
QString TagName() const {return tagName;} inline QString TagName() const {return tagName;}
qint32 LineNumber() const {return lineNumber;} inline qint32 LineNumber() const {return lineNumber;}
protected: protected:
QString tagText; QString tagText;
QString tagName; QString tagName;
qint32 lineNumber; qint32 lineNumber;
}; };
#endif // VEXCEPTIONUNIQUEID_H #endif // VEXCEPTIONUNIQUEID_H

View File

@ -31,10 +31,6 @@ VExceptionWrongParameterId::VExceptionWrongParameterId(const QString &what, cons
lineNumber = domElement.lineNumber(); lineNumber = domElement.lineNumber();
} }
VExceptionWrongParameterId::VExceptionWrongParameterId(const VExceptionWrongParameterId &e):VException(e),
tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.LineNumber()){
}
QString VExceptionWrongParameterId::ErrorMessage() const{ QString VExceptionWrongParameterId::ErrorMessage() const{
QString error = QString("ExceptionWrongParameterId: %1").arg(what); QString error = QString("ExceptionWrongParameterId: %1").arg(what);
return error; return error;

View File

@ -23,23 +23,22 @@
#define VEXCEPTIONWRONGPARAMETERID_H #define VEXCEPTIONWRONGPARAMETERID_H
#include "vexception.h" #include "vexception.h"
#include <QDomElement>
class VExceptionWrongParameterId : public VException class VExceptionWrongParameterId : public VException{
{
public: public:
VExceptionWrongParameterId(const QString &what, const QDomElement &domElement); VExceptionWrongParameterId(const QString &what, const QDomElement &domElement);
VExceptionWrongParameterId(const VExceptionWrongParameterId &e); VExceptionWrongParameterId(const VExceptionWrongParameterId &e):VException(e),tagText(e.TagText()),
virtual ~VExceptionWrongParameterId() noexcept(true){} tagName(e.TagName()), lineNumber(e.LineNumber()){}
virtual ~VExceptionWrongParameterId() noexcept(true){}
virtual QString ErrorMessage() const; virtual QString ErrorMessage() const;
virtual QString DetailedInformation() const; virtual QString DetailedInformation() const;
QString TagText() const {return tagText;} inline QString TagText() const {return tagText;}
QString TagName() const {return tagName;} inline QString TagName() const {return tagName;}
qint32 LineNumber() const {return lineNumber;} inline qint32 LineNumber() const {return lineNumber;}
protected: protected:
QString tagText; QString tagText;
QString tagName; QString tagName;
qint32 lineNumber; qint32 lineNumber;
}; };
#endif // VEXCEPTIONWRONGPARAMETERID_H #endif // VEXCEPTIONWRONGPARAMETERID_H