Seamly2D
Code documentation
vexceptionemptyparameter.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 vexceptionemptyparameter.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 
53 
54 #include <QDomElement>
55 #include <QTextStream>
56 
57 #include "vexception.h"
58 
59 //---------------------------------------------------------------------------------------------------------------------
60 /**
61  * @brief VExceptionEmptyParameter exception empty parameter
62  * @param what string with error
63  * @param name name of attribute where error
64  * @param domElement dom element
65  */
66 VExceptionEmptyParameter::VExceptionEmptyParameter(const QString &what, const QString &name,
67  const QDomElement &domElement)
68  : VException(what), name(name), tagText(QString()), tagName(QString()), lineNumber(-1)
69 {
70  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
71  Q_ASSERT_X(not name.isEmpty(), Q_FUNC_INFO, "Parameter name is empty");
72  QTextStream stream(&tagText);
73  domElement.save(stream, 4);
74  tagName = domElement.tagName();
75  lineNumber = domElement.lineNumber();
76 }
77 
78 //---------------------------------------------------------------------------------------------------------------------
79 /**
80  * @brief VExceptionEmptyParameter copy constructor
81  * @param e exception
82  */
84  :VException(e), name(e.Name()), tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.LineNumber())
85 {}
86 
87 //---------------------------------------------------------------------------------------------------------------------
89 {
90  if ( &e == this )
91  {
92  return *this;
93  }
95  name = e.Name();
96  tagText = e.TagText();
97  tagName = e.TagName();
98  lineNumber = e.LineNumber();
99  return *this;
100 }
101 
102 //---------------------------------------------------------------------------------------------------------------------
103 /**
104  * @brief ErrorMessage return main error message
105  * @return main error message
106  */
108 {
109  return QString("ExceptionEmptyParameter: %1 %2").arg(error, name);
110 }
111 
112 //---------------------------------------------------------------------------------------------------------------------
113 /**
114  * @brief DetailedInformation return detailed information about error
115  * @return detailed information
116  */
118 {
119  return MoreInfo(QString("tag: %1 in line %2\nFull tag:\n%3").arg(tagName).arg(lineNumber).arg(tagText));
120 }
The VExceptionEmptyParameter class for exception empty parameter.
qint32 LineNumber() const
LineNumber return line number of tag.
QString Name() const
Name return name of attribute where error.
VExceptionEmptyParameter(const QString &what, const QString &name, const QDomElement &domElement)
VExceptionEmptyParameter exception empty parameter.
virtual QString ErrorMessage() const Q_DECL_OVERRIDE
ErrorMessage return main error message.
QString TagText() const
TagText return tag text.
QString tagText
tagText tag text
QString tagName
tagName tag name
QString TagName() const
TagName return tag name.
qint32 lineNumber
lineNumber line number
virtual QString DetailedInformation() const Q_DECL_OVERRIDE
DetailedInformation return detailed information about error.
VExceptionEmptyParameter & operator=(const VExceptionEmptyParameter &e)
QString name
name name attribute
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