QGIS API Documentation  2.99.0-Master (0cba29c)
qgserror.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgserror.h - Error container
3  -------------------
4  begin : October 2012
5  copyright : (C) 2012 Radim Blazek
6  email : radim dot blazek at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 #ifndef QGSERROR_H
18 #define QGSERROR_H
19 
20 #include <QString>
21 #include <QList>
22 
23 #include "qgis_core.h"
24 
25 // Macro to create Error message including info about where it was created.
26 #define QGS_ERROR_MESSAGE(message, tag) QgsErrorMessage(QString(message),QString(tag), QString(__FILE__), QString(__FUNCTION__), __LINE__)
27 
31 class CORE_EXPORT QgsErrorMessage
32 {
33  public:
35  enum Format
36  {
37  Text, // Plain text
38  Html
39  };
40 
42  : mLine( 0 )
43  , mFormat( Text )
44  {}
45 
53  QgsErrorMessage( const QString &message, const QString &tag = QString(), const QString &file = QString(), const QString &function = QString(), int line = 0 );
54 
55  QString message() const { return mMessage; }
56  QString tag() const { return mTag; }
57  QString file() const { return mFile; }
58  QString function() const { return mFunction; }
59  int line() const { return mLine; }
60 
61  private:
63  QString mMessage;
64 
66  QString mTag;
67 
69  QString mFile;
70  QString mFunction;
71  int mLine;
72 
74  Format mFormat;
75 };
76 
82 class CORE_EXPORT QgsError
83 {
84  public:
85 
86  QgsError() {}
87 
92  QgsError( const QString &message, const QString &tag );
93 
98  void append( const QString &message, const QString &tag );
99 
103  void append( const QgsErrorMessage &message );
104 
108  bool isEmpty() const { return mMessageList.isEmpty(); }
109 
114  QString message( QgsErrorMessage::Format format = QgsErrorMessage::Html ) const;
115 
119  QString summary() const;
120 
122  void clear() { mMessageList.clear(); }
123 
124  private:
126  QList<QgsErrorMessage> mMessageList;
127 };
128 
129 #endif
QString message() const
Definition: qgserror.h:55
bool isEmpty() const
Test if any error is set.
Definition: qgserror.h:108
Format
Format.
Definition: qgserror.h:35
QgsErrorMessage represents single error message.
Definition: qgserror.h:31
int line() const
Definition: qgserror.h:59
QgsError is container for error messages (report).
Definition: qgserror.h:82
QString tag() const
Definition: qgserror.h:56
QgsError()
Definition: qgserror.h:86
QString file() const
Definition: qgserror.h:57
void clear()
Clear error messages.
Definition: qgserror.h:122