Left only one exception.
--HG-- branch : feature
This commit is contained in:
parent
2ca2595968
commit
b15bb4fd33
|
@ -1,17 +1,15 @@
|
|||
HEADERS += \
|
||||
src/exception/vexceptionwrongparameterid.h \
|
||||
src/exception/vexceptionuniqueid.h \
|
||||
src/exception/vexceptionobjecterror.h \
|
||||
src/exception/vexceptionemptyparameter.h \
|
||||
src/exception/vexceptionconversionerror.h \
|
||||
src/exception/vexceptionbadid.h \
|
||||
src/exception/vexception.h
|
||||
src/exception/vexception.h \
|
||||
src/exception/vexceptionwrongid.h
|
||||
|
||||
SOURCES += \
|
||||
src/exception/vexceptionwrongparameterid.cpp \
|
||||
src/exception/vexceptionuniqueid.cpp \
|
||||
src/exception/vexceptionobjecterror.cpp \
|
||||
src/exception/vexceptionemptyparameter.cpp \
|
||||
src/exception/vexceptionconversionerror.cpp \
|
||||
src/exception/vexceptionbadid.cpp \
|
||||
src/exception/vexception.cpp
|
||||
src/exception/vexception.cpp \
|
||||
src/exception/vexceptionwrongid.cpp
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vexceptionuniqueid.cpp
|
||||
** @file vexceptionwrongparameterid.cpp
|
||||
** @author Roman Telezhinsky <dismine@gmail.com>
|
||||
** @date November 15, 2013
|
||||
**
|
||||
|
@ -26,11 +26,10 @@
|
|||
**
|
||||
*************************************************************************/
|
||||
|
||||
#include "vexceptionuniqueid.h"
|
||||
#include "vexceptionwrongid.h"
|
||||
#include <QDebug>
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
VExceptionUniqueId::VExceptionUniqueId(const QString &what, const QDomElement &domElement)
|
||||
VExceptionWrongId::VExceptionWrongId(const QString &what, const QDomElement &domElement)
|
||||
:VException(what), tagText(QString()), tagName(QString()), lineNumber(-1)
|
||||
{
|
||||
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
||||
|
@ -40,19 +39,19 @@ VExceptionUniqueId::VExceptionUniqueId(const QString &what, const QDomElement &d
|
|||
lineNumber = domElement.lineNumber();
|
||||
}
|
||||
|
||||
VExceptionUniqueId::VExceptionUniqueId(const VExceptionUniqueId &e)
|
||||
VExceptionWrongId::VExceptionWrongId(const VExceptionWrongId &e)
|
||||
:VException(e), tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.LineNumber())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString VExceptionUniqueId::ErrorMessage() const
|
||||
QString VExceptionWrongId::ErrorMessage() const
|
||||
{
|
||||
QString error = QString("ExceptionUniqueId: %1").arg(what);
|
||||
QString error = QString("ExceptionWrongId: %1").arg(what);
|
||||
return error;
|
||||
}
|
||||
|
||||
QString VExceptionUniqueId::DetailedInformation() const
|
||||
QString VExceptionWrongId::DetailedInformation() const
|
||||
{
|
||||
QString detail = QString("tag: %1 in line %2\nFull tag:\n%3").arg(tagName).arg(lineNumber).arg(tagText);
|
||||
return detail;
|
|
@ -1,6 +1,6 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vexceptionuniqueid.h
|
||||
** @file vexceptionwrongparameterid.h
|
||||
** @author Roman Telezhinsky <dismine@gmail.com>
|
||||
** @date November 15, 2013
|
||||
**
|
||||
|
@ -26,31 +26,31 @@
|
|||
**
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef VEXCEPTIONUNIQUEID_H
|
||||
#define VEXCEPTIONUNIQUEID_H
|
||||
#ifndef VEXCEPTIONWRONGID_H
|
||||
#define VEXCEPTIONWRONGID_H
|
||||
|
||||
#include "vexception.h"
|
||||
|
||||
#include <QDomElement>
|
||||
|
||||
/**
|
||||
* @brief The VExceptionUniqueId class for exception unique id
|
||||
* @brief The VExceptionWrongId class for exception wrong id
|
||||
*/
|
||||
class VExceptionUniqueId : public VException
|
||||
class VExceptionWrongId : public VException
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief VExceptionUniqueId exception unique id
|
||||
* @brief VExceptionWrongId exception wrong parameter id
|
||||
* @param what string with error
|
||||
* @param domElement dom element
|
||||
* @param domElement som element
|
||||
*/
|
||||
VExceptionUniqueId(const QString &what, const QDomElement &domElement);
|
||||
VExceptionWrongId(const QString &what, const QDomElement &domElement);
|
||||
/**
|
||||
* @brief VExceptionUniqueId copy constructor
|
||||
* @brief VExceptionWrongId copy constructor
|
||||
* @param e exception
|
||||
*/
|
||||
VExceptionUniqueId(const VExceptionUniqueId &e);
|
||||
virtual ~VExceptionUniqueId() noexcept (true){}
|
||||
VExceptionWrongId(const VExceptionWrongId &e);
|
||||
virtual ~VExceptionWrongId() noexcept (true){}
|
||||
/**
|
||||
* @brief ErrorMessage return main error message
|
||||
* @return main error message
|
||||
|
@ -91,19 +91,19 @@ protected:
|
|||
qint32 lineNumber;
|
||||
};
|
||||
|
||||
inline QString VExceptionUniqueId::TagText() const
|
||||
inline QString VExceptionWrongId::TagText() const
|
||||
{
|
||||
return tagText;
|
||||
}
|
||||
|
||||
inline QString VExceptionUniqueId::TagName() const
|
||||
inline QString VExceptionWrongId::TagName() const
|
||||
{
|
||||
return tagName;
|
||||
}
|
||||
|
||||
inline qint32 VExceptionUniqueId::LineNumber() const
|
||||
inline qint32 VExceptionWrongId::LineNumber() const
|
||||
{
|
||||
return lineNumber;
|
||||
}
|
||||
|
||||
#endif // VEXCEPTIONUNIQUEID_H
|
||||
#endif // VEXCEPTIONWRONGID_H
|
|
@ -1,58 +0,0 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vexceptionwrongparameterid.cpp
|
||||
** @author Roman Telezhinsky <dismine@gmail.com>
|
||||
** @date November 15, 2013
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentine project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2013 Valentina project
|
||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#include "vexceptionwrongparameterid.h"
|
||||
#include <QDebug>
|
||||
|
||||
VExceptionWrongParameterId::VExceptionWrongParameterId(const QString &what, const QDomElement &domElement)
|
||||
:VException(what), tagText(QString()), tagName(QString()), lineNumber(-1)
|
||||
{
|
||||
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
||||
QTextStream stream(&tagText);
|
||||
domElement.save(stream, 4);
|
||||
tagName = domElement.tagName();
|
||||
lineNumber = domElement.lineNumber();
|
||||
}
|
||||
|
||||
VExceptionWrongParameterId::VExceptionWrongParameterId(const VExceptionWrongParameterId &e)
|
||||
:VException(e), tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.LineNumber())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString VExceptionWrongParameterId::ErrorMessage() const
|
||||
{
|
||||
QString error = QString("ExceptionWrongParameterId: %1").arg(what);
|
||||
return error;
|
||||
}
|
||||
|
||||
QString VExceptionWrongParameterId::DetailedInformation() const
|
||||
{
|
||||
QString detail = QString("tag: %1 in line %2\n%3").arg(tagName).arg(lineNumber).arg(tagText);
|
||||
return detail;
|
||||
}
|
|
@ -1,109 +0,0 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vexceptionwrongparameterid.h
|
||||
** @author Roman Telezhinsky <dismine@gmail.com>
|
||||
** @date November 15, 2013
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentine project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2013 Valentina project
|
||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef VEXCEPTIONWRONGPARAMETERID_H
|
||||
#define VEXCEPTIONWRONGPARAMETERID_H
|
||||
|
||||
#include "vexception.h"
|
||||
|
||||
#include <QDomElement>
|
||||
|
||||
/**
|
||||
* @brief The VExceptionWrongParameterId class for exception wrong parameter id
|
||||
*/
|
||||
class VExceptionWrongParameterId : public VException
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief VExceptionWrongParameterId exception wrong parameter id
|
||||
* @param what string with error
|
||||
* @param domElement som element
|
||||
*/
|
||||
VExceptionWrongParameterId(const QString &what, const QDomElement &domElement);
|
||||
/**
|
||||
* @brief VExceptionWrongParameterId copy constructor
|
||||
* @param e exception
|
||||
*/
|
||||
VExceptionWrongParameterId(const VExceptionWrongParameterId &e);
|
||||
virtual ~VExceptionWrongParameterId() noexcept (true){}
|
||||
/**
|
||||
* @brief ErrorMessage return main error message
|
||||
* @return main error message
|
||||
*/
|
||||
virtual QString ErrorMessage() const;
|
||||
/**
|
||||
* @brief DetailedInformation return detailed information about error
|
||||
* @return detailed information
|
||||
*/
|
||||
virtual QString DetailedInformation() const;
|
||||
/**
|
||||
* @brief TagText return tag text
|
||||
* @return tag text
|
||||
*/
|
||||
QString TagText() const;
|
||||
/**
|
||||
* @brief TagName return tag name
|
||||
* @return tag name
|
||||
*/
|
||||
QString TagName() const;
|
||||
/**
|
||||
* @brief LineNumber return line number in file
|
||||
* @return line number
|
||||
*/
|
||||
qint32 LineNumber() const;
|
||||
protected:
|
||||
/**
|
||||
* @brief tagText tag text
|
||||
*/
|
||||
QString tagText;
|
||||
/**
|
||||
* @brief tagName tag name
|
||||
*/
|
||||
QString tagName;
|
||||
/**
|
||||
* @brief lineNumber line number
|
||||
*/
|
||||
qint32 lineNumber;
|
||||
};
|
||||
|
||||
inline QString VExceptionWrongParameterId::TagText() const
|
||||
{
|
||||
return tagText;
|
||||
}
|
||||
|
||||
inline QString VExceptionWrongParameterId::TagName() const
|
||||
{
|
||||
return tagName;
|
||||
}
|
||||
|
||||
inline qint32 VExceptionWrongParameterId::LineNumber() const
|
||||
{
|
||||
return lineNumber;
|
||||
}
|
||||
|
||||
#endif // VEXCEPTIONWRONGPARAMETERID_H
|
|
@ -33,8 +33,7 @@
|
|||
#include "exception/vexceptionobjecterror.h"
|
||||
#include "exception/vexceptionconversionerror.h"
|
||||
#include "exception/vexceptionemptyparameter.h"
|
||||
#include "exception/vexceptionwrongparameterid.h"
|
||||
#include "exception/vexceptionuniqueid.h"
|
||||
#include "exception/vexceptionwrongid.h"
|
||||
#include "version.h"
|
||||
|
||||
#include <QInputDialog>
|
||||
|
@ -1074,7 +1073,7 @@ bool MainWindow::SavePattern(const QString &fileName)
|
|||
{
|
||||
doc->TestUniqueId();
|
||||
}
|
||||
catch (const VExceptionUniqueId &e)
|
||||
catch (const VExceptionWrongId &e)
|
||||
{
|
||||
e.CriticalMessageBox(tr("Error no unique id."), this);
|
||||
return false;
|
||||
|
@ -1400,20 +1399,13 @@ void MainWindow::LoadPattern(const QString &fileName)
|
|||
Clear();
|
||||
return;
|
||||
}
|
||||
catch (const VExceptionWrongParameterId &e)
|
||||
catch (const VExceptionWrongId &e)
|
||||
{
|
||||
e.CriticalMessageBox(tr("Error wrong id."), this);
|
||||
file.close();
|
||||
Clear();
|
||||
return;
|
||||
}
|
||||
catch (const VExceptionUniqueId &e)
|
||||
{
|
||||
e.CriticalMessageBox(tr("Error no unique id."), this);
|
||||
file.close();
|
||||
Clear();
|
||||
return;
|
||||
}
|
||||
connect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||
this, &MainWindow::currentDrawChanged);
|
||||
QString nameDraw = doc->GetNameActivDraw();
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include "../exception/vexceptionbadid.h"
|
||||
#include "../exception/vexceptionconversionerror.h"
|
||||
#include "../exception/vexceptionemptyparameter.h"
|
||||
#include "../exception/vexceptionwrongparameterid.h"
|
||||
#include "../exception/vexceptionwrongid.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QDebug>
|
||||
|
@ -63,7 +63,7 @@ bool VApplication::notify(QObject *receiver, QEvent *event)
|
|||
e.CriticalMessageBox(tr("Error empty parameter. Program will be terminated."));
|
||||
abort();
|
||||
}
|
||||
catch (const VExceptionWrongParameterId &e)
|
||||
catch (const VExceptionWrongId &e)
|
||||
{
|
||||
e.CriticalMessageBox(tr("Error wrong id. Program will be terminated."));
|
||||
abort();
|
||||
|
|
|
@ -33,8 +33,7 @@
|
|||
#include "../tools/drawTools/drawtools.h"
|
||||
#include "../tools/nodeDetails/nodedetails.h"
|
||||
#include "../exception/vexceptionobjecterror.h"
|
||||
#include "../exception/vexceptionwrongparameterid.h"
|
||||
#include "../exception/vexceptionuniqueid.h"
|
||||
#include "../exception/vexceptionwrongid.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
|
@ -1254,7 +1253,7 @@ quint32 VPattern::GetParametrId(const QDomElement &domElement) const
|
|||
const quint32 id = GetParametrUInt(domElement, VAbstractTool::AttrId, "0");
|
||||
if (id <= 0)
|
||||
{
|
||||
throw VExceptionWrongParameterId(tr("Got wrong parameter id. Need only id > 0."), domElement);
|
||||
throw VExceptionWrongId(tr("Got wrong parameter id. Need only id > 0."), domElement);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
@ -1266,7 +1265,7 @@ void VPattern::CollectId(const QDomElement &node, QVector<quint32> &vector) cons
|
|||
const quint32 id = GetParametrId(node);
|
||||
if (vector.contains(id))
|
||||
{
|
||||
throw VExceptionUniqueId(tr("This id is not unique."), node);
|
||||
throw VExceptionWrongId(tr("This id is not unique."), node);
|
||||
}
|
||||
vector.append(id);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user