From b15bb4fd334205454f63070a44c4d22113e335b8 Mon Sep 17 00:00:00 2001 From: dismine Date: Mon, 3 Mar 2014 19:32:38 +0200 Subject: [PATCH] Left only one exception. --HG-- branch : feature --- src/exception/exception.pri | 10 +- ...tionuniqueid.cpp => vexceptionwrongid.cpp} | 17 ++- ...xceptionuniqueid.h => vexceptionwrongid.h} | 30 ++--- src/exception/vexceptionwrongparameterid.cpp | 58 ---------- src/exception/vexceptionwrongparameterid.h | 109 ------------------ src/mainwindow.cpp | 14 +-- src/widgets/vapplication.cpp | 4 +- src/xml/vpattern.cpp | 7 +- 8 files changed, 35 insertions(+), 214 deletions(-) rename src/exception/{vexceptionuniqueid.cpp => vexceptionwrongid.cpp} (80%) rename src/exception/{vexceptionuniqueid.h => vexceptionwrongid.h} (76%) delete mode 100644 src/exception/vexceptionwrongparameterid.cpp delete mode 100644 src/exception/vexceptionwrongparameterid.h diff --git a/src/exception/exception.pri b/src/exception/exception.pri index 3e0166be0..a743115fc 100644 --- a/src/exception/exception.pri +++ b/src/exception/exception.pri @@ -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 diff --git a/src/exception/vexceptionuniqueid.cpp b/src/exception/vexceptionwrongid.cpp similarity index 80% rename from src/exception/vexceptionuniqueid.cpp rename to src/exception/vexceptionwrongid.cpp index 6578290ca..ac78b1d99 100644 --- a/src/exception/vexceptionuniqueid.cpp +++ b/src/exception/vexceptionwrongid.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vexceptionuniqueid.cpp + ** @file vexceptionwrongparameterid.cpp ** @author Roman Telezhinsky ** @date November 15, 2013 ** @@ -26,11 +26,10 @@ ** *************************************************************************/ -#include "vexceptionuniqueid.h" +#include "vexceptionwrongid.h" +#include -#include - -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; diff --git a/src/exception/vexceptionuniqueid.h b/src/exception/vexceptionwrongid.h similarity index 76% rename from src/exception/vexceptionuniqueid.h rename to src/exception/vexceptionwrongid.h index 8125c2966..22be31c60 100644 --- a/src/exception/vexceptionuniqueid.h +++ b/src/exception/vexceptionwrongid.h @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vexceptionuniqueid.h + ** @file vexceptionwrongparameterid.h ** @author Roman Telezhinsky ** @date November 15, 2013 ** @@ -26,31 +26,31 @@ ** *************************************************************************/ -#ifndef VEXCEPTIONUNIQUEID_H -#define VEXCEPTIONUNIQUEID_H +#ifndef VEXCEPTIONWRONGID_H +#define VEXCEPTIONWRONGID_H #include "vexception.h" #include /** - * @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 diff --git a/src/exception/vexceptionwrongparameterid.cpp b/src/exception/vexceptionwrongparameterid.cpp deleted file mode 100644 index 0e99ee018..000000000 --- a/src/exception/vexceptionwrongparameterid.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/************************************************************************ - ** - ** @file vexceptionwrongparameterid.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 . - ** - *************************************************************************/ - -#include "vexceptionwrongparameterid.h" -#include - -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; -} diff --git a/src/exception/vexceptionwrongparameterid.h b/src/exception/vexceptionwrongparameterid.h deleted file mode 100644 index 55879c986..000000000 --- a/src/exception/vexceptionwrongparameterid.h +++ /dev/null @@ -1,109 +0,0 @@ -/************************************************************************ - ** - ** @file vexceptionwrongparameterid.h - ** @author Roman Telezhinsky - ** @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 - ** 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 . - ** - *************************************************************************/ - -#ifndef VEXCEPTIONWRONGPARAMETERID_H -#define VEXCEPTIONWRONGPARAMETERID_H - -#include "vexception.h" - -#include - -/** - * @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 diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 99be787f5..315ef1196 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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 @@ -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(&QComboBox::currentIndexChanged), this, &MainWindow::currentDrawChanged); QString nameDraw = doc->GetNameActivDraw(); diff --git a/src/widgets/vapplication.cpp b/src/widgets/vapplication.cpp index 16664f94a..6686f8faf 100644 --- a/src/widgets/vapplication.cpp +++ b/src/widgets/vapplication.cpp @@ -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 #include @@ -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(); diff --git a/src/xml/vpattern.cpp b/src/xml/vpattern.cpp index 633734c8c..3c265a8e5 100644 --- a/src/xml/vpattern.cpp +++ b/src/xml/vpattern.cpp @@ -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 @@ -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 &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); }