QGIS API Documentation  3.4.15-Madeira (e83d02e274)
qgsserverexception.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgserverexception.h
3  ------------------------
4  begin : January 11, 2017
5  copyright : (C) 2017 by David Marteau
6  email : david dot marteau at 3liz 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 
18 #ifndef QGSSERVEREXCEPTION_H
19 #define QGSSERVEREXCEPTION_H
20 
21 #include <QString>
22 #include <QByteArray>
23 
24 #include "qgsexception.h"
25 #include "qgis_server.h"
26 #include "qgis_sip.h"
27 
28 
35 #ifndef SIP_RUN
36 class SERVER_EXPORT QgsServerException : public QgsException
37 {
38 #else
39 class SERVER_EXPORT QgsServerException
40 {
41 #endif
42  public:
44  QgsServerException( const QString &message, int responseCode = 500 );
45 
49  int responseCode() const { return mResponseCode; }
50 
59  virtual QByteArray formatResponse( QString &responseFormat SIP_OUT ) const;
60 
61  private:
62  int mResponseCode;
63 };
64 
75 #ifndef SIP_RUN
76 class SERVER_EXPORT QgsOgcServiceException : public QgsServerException
77 {
78 #else
79 class SERVER_EXPORT QgsOgcServiceException
80 {
81 #endif
82  public:
84  QgsOgcServiceException( const QString &code, const QString &message, const QString &locator = QString(),
85  int responseCode = 200, const QString &version = QStringLiteral( "1.3.0" ) );
86 
88  QString message() const { return mMessage; }
89 
91  QString code() const { return mCode; }
92 
94  QString locator() const { return mLocator; }
95 
97  QString version() const { return mVersion; }
98 
99  QByteArray formatResponse( QString &responseFormat SIP_OUT ) const override;
100 
101  private:
102  QString mCode;
103  QString mMessage;
104  QString mLocator;
105  QString mVersion;
106 };
107 
114 #ifndef SIP_RUN
115 class SERVER_EXPORT QgsBadRequestException: public QgsOgcServiceException
116 {
117  public:
118 
125  QgsBadRequestException( const QString &code, const QString &message, const QString &locator = QString() )
126  : QgsOgcServiceException( code, message, locator, 400 )
127  {}
128 };
129 #endif
130 
131 #endif
QString locator() const
Returns the locator.
Exception thrown in case of malformed request.
QgsBadRequestException(const QString &code, const QString &message, const QString &locator=QString())
Constructor for QgsBadRequestException (HTTP error code 400).
Exception base class for service exceptions.
int responseCode() const
Exception base class for server exceptions.
#define SIP_OUT
Definition: qgis_sip.h:51
QString code() const
Returns the exception code.
QString version() const
Returns the exception version.
QString message() const
Returns the exception message.
Defines a QGIS exception class.
Definition: qgsexception.h:34