Seamly2D
Code documentation
vexception.h
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 vexception.h
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 #ifndef VEXCEPTION_H
53 #define VEXCEPTION_H
54 
55 #include <qcompilerdetection.h>
56 #include <QCoreApplication>
57 #include <QException>
58 #include <QString>
59 
60 #include "../ifcdef.h"
61 
62 /**
63  * @brief The VException class parent for all exception. Could be use for abstract exception
64  */
65 class VException : public QException
66 {
67  Q_DECLARE_TR_FUNCTIONS(VException)
68 public:
69  explicit VException(const QString &error);
70  VException(const VException &e);
71  VException &operator=(const VException &e);
72  virtual ~VException() V_NOEXCEPT_EXPR (true) Q_DECL_EQ_DEFAULT;
73 
74  Q_NORETURN virtual void raise() const Q_DECL_OVERRIDE;
75 
76  // cppcheck-suppress unusedFunction
77  Q_REQUIRED_RESULT virtual VException *clone() const Q_DECL_OVERRIDE;
78 
79  virtual QString ErrorMessage() const;
80  virtual QString DetailedInformation() const;
81  QString WhatUtf8() const V_NOEXCEPT_EXPR (true);
82  void AddMoreInformation(const QString &info);
83  QString MoreInformation() const;
84  virtual const char* what() const V_NOEXCEPT_EXPR (true) Q_DECL_OVERRIDE;
85 
86 protected:
87  /** @brief error string with error */
88  QString error;
89 
90  /** @brief moreInfo more information about error */
91  QString moreInfo;
92 
93  QString MoreInfo(const QString &detInfo) const;
94 };
95 
96 //---------------------------------------------------------------------------------------------------------------------
97 /**
98  * @brief What return string with error
99  * @return string with error
100  */
101 inline QString VException::WhatUtf8() const V_NOEXCEPT_EXPR (true)
102 {
103  return error;
104 }
105 
106 //---------------------------------------------------------------------------------------------------------------------
107 /**
108  * @brief MoreInformation return more information for error
109  * @return information
110  */
111 inline QString VException::MoreInformation() const
112 {
113  return moreInfo;
114 }
115 
116 // Want have special exception for catching unhadled deleting a tool
118 {
119  Q_DECLARE_TR_FUNCTIONS(VExceptionToolDeleted)
120 public:
121  explicit VExceptionToolWasDeleted(const QString &error);
124  virtual ~VExceptionToolWasDeleted() V_NOEXCEPT_EXPR (true) Q_DECL_EQ_DEFAULT;
125 
126  Q_NORETURN virtual void raise() const Q_DECL_OVERRIDE;
127  // cppcheck-suppress unusedFunction
128  virtual VExceptionToolWasDeleted *clone() const Q_DECL_OVERRIDE;
129 };
130 
131 #endif // VEXCEPTION_H
virtual ~VExceptionToolWasDeleted() Q_DECL_EQ_DEFAULT
The VException class parent for all exception. Could be use for abstract exception.
Definition: vexception.h:66
virtual Q_REQUIRED_RESULT VException * clone() const Q_DECL_OVERRIDE
clone clone exception
Definition: vexception.cpp:145
QString MoreInfo(const QString &detInfo) const
Definition: vexception.cpp:117
VException(const QString &error)
VException constructor exception.
Definition: vexception.cpp:66
QString MoreInformation() const
MoreInformation return more information for error.
Definition: vexception.h:111
virtual QString ErrorMessage() const
ErrorMessage return main error message.
Definition: vexception.cpp:97
QString error
error string with error
Definition: vexception.h:88
void AddMoreInformation(const QString &info)
AddMoreInformation add more information for error.
Definition: vexception.cpp:107
virtual const char * what() const Q_DECL_OVERRIDE
Definition: vexception.cpp:161
QString moreInfo
moreInfo more information about error
Definition: vexception.h:91
VException & operator=(const VException &e)
Definition: vexception.cpp:81
virtual ~VException() Q_DECL_EQ_DEFAULT
QString WhatUtf8() const
What return string with error.
Definition: vexception.h:101
virtual QString DetailedInformation() const
DetailedInformation return detailed information about error.
Definition: vexception.cpp:134
virtual Q_NORETURN void raise() const Q_DECL_OVERRIDE
raise method raise for exception
Definition: vexception.cpp:155
#define V_NOEXCEPT_EXPR(x)
Definition: ifcdef.h:91