Seamly2D
Code documentation
vexceptionwrongid.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * *
3  * Copyright (C) 2017 Seamly, LLC *
4  * *
5  * https://github.com/fashionfreedom/seamly2d *
6  * *
7  ***************************************************************************
8  **
9  ** Seamly2D is free software: you can redistribute it and/or modify
10  ** it under the terms of the GNU General Public License as published by
11  ** the Free Software Foundation, either version 3 of the License, or
12  ** (at your option) any later version.
13  **
14  ** Seamly2D is distributed in the hope that it will be useful,
15  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  ** GNU General Public License for more details.
18  **
19  ** You should have received a copy of the GNU General Public License
20  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
21  **
22  **************************************************************************
23 
24  ************************************************************************
25  **
26  ** @file vexceptionwrongparameterid.cpp
27  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
28  ** @date November 15, 2013
29  **
30  ** @brief
31  ** @copyright
32  ** This source code is part of the Valentine project, a pattern making
33  ** program, whose allow create and modeling patterns of clothing.
34  ** Copyright (C) 2013-2015 Seamly2D project
35  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
36  **
37  ** Seamly2D is free software: you can redistribute it and/or modify
38  ** it under the terms of the GNU General Public License as published by
39  ** the Free Software Foundation, either version 3 of the License, or
40  ** (at your option) any later version.
41  **
42  ** Seamly2D is distributed in the hope that it will be useful,
43  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
44  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45  ** GNU General Public License for more details.
46  **
47  ** You should have received a copy of the GNU General Public License
48  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
49  **
50  *************************************************************************/
51 
52 #include "vexceptionwrongid.h"
53 
54 #include <QDomElement>
55 #include <QTextStream>
56 
57 #include "vexception.h"
58 
59 //---------------------------------------------------------------------------------------------------------------------
60 /**
61  * @brief VExceptionWrongId exception wrong parameter id
62  * @param what string with error
63  * @param domElement som element
64  */
65 VExceptionWrongId::VExceptionWrongId(const QString &what, const QDomElement &domElement)
66  :VException(what), tagText(QString()), tagName(QString()), lineNumber(-1)
67 {
68  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
69  QTextStream stream(&tagText);
70  domElement.save(stream, 4);
71  tagName = domElement.tagName();
72  lineNumber = domElement.lineNumber();
73 }
74 
75 //---------------------------------------------------------------------------------------------------------------------
76 /**
77  * @brief VExceptionWrongId copy constructor
78  * @param e exception
79  */
81  :VException(e), tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.LineNumber())
82 {}
83 
84 //---------------------------------------------------------------------------------------------------------------------
86 {
87  if ( &e == this )
88  {
89  return *this;
90  }
92  tagText = e.TagText();
93  tagName = e.TagName();
94  lineNumber = e.LineNumber();
95  return *this;
96 }
97 
98 //---------------------------------------------------------------------------------------------------------------------
99 /**
100  * @brief ErrorMessage return main error message
101  * @return main error message
102  */
104 {
105  return QString("ExceptionWrongId: %1").arg(error);
106 }
107 
108 //---------------------------------------------------------------------------------------------------------------------
109 /**
110  * @brief DetailedInformation return detailed information about error
111  * @return detailed information
112  */
114 {
115  return MoreInfo(QString("tag: %1 in line %2\nFull tag:\n%3").arg(tagName).arg(lineNumber).arg(tagText));
116 }
The VExceptionWrongId class for exception wrong id.
QString TagName() const
TagName return tag name.
VExceptionWrongId(const QString &what, const QDomElement &domElement)
VExceptionWrongId exception wrong parameter id.
QString tagText
tagText tag text
virtual QString DetailedInformation() const Q_DECL_OVERRIDE
DetailedInformation return detailed information about error.
qint32 lineNumber
lineNumber line number
virtual QString ErrorMessage() const Q_DECL_OVERRIDE
ErrorMessage return main error message.
QString tagName
tagName tag name
QString TagText() const
TagText return tag text.
VExceptionWrongId & operator=(const VExceptionWrongId &e)
qint32 LineNumber() const
LineNumber return line number in file.
The VException class parent for all exception. Could be use for abstract exception.
Definition: vexception.h:66
QString MoreInfo(const QString &detInfo) const
Definition: vexception.cpp:117
QString error
error string with error
Definition: vexception.h:88
VException & operator=(const VException &e)
Definition: vexception.cpp:81