QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
server
qgsserverexception.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsservervexception.h
3
-------------------
4
begin : January 11, 2017
5
copyright : (C) 2017 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
#include "
qgsserverexception.h
"
19
20
#include <QDomDocument>
21
#include <QString>
22
23
using namespace
Qt::StringLiterals;
24
25
// QgsServerException
26
QgsServerException::QgsServerException
(
const
QString &message,
int
responseCode
)
27
:
QgsException
( message )
28
, mResponseCode(
responseCode
)
29
{}
30
31
QByteArray
QgsServerException::formatResponse
( QString &responseFormat )
const
32
{
33
QDomDocument doc;
34
const
QDomNode header = doc.createProcessingInstruction( u
"xml"
_s, u
"version=\"1.0\" encoding=\"UTF-8\""
_s );
35
doc.appendChild( header );
36
37
QDomElement root = doc.createElement( u
"ServerException"
_s );
38
doc.appendChild( root );
39
root.appendChild( doc.createTextNode(
what
() ) );
40
41
responseFormat = u
"text/xml; charset=utf-8"
_s;
42
return
doc.toByteArray();
43
}
44
45
46
// QgsOgcServiceException
47
QgsOgcServiceException::QgsOgcServiceException
(
const
QString &
code
,
const
QString &
message
,
const
QString &
locator
,
int
responseCode
,
const
QString &
version
)
48
:
QgsServerException
(
message
,
responseCode
)
49
, mCode(
code
)
50
, mMessage(
message
)
51
, mLocator(
locator
)
52
, mVersion(
version
)
53
{}
54
55
QByteArray
QgsOgcServiceException::formatResponse
( QString &responseFormat )
const
56
{
57
QDomDocument doc;
58
const
QDomNode header = doc.createProcessingInstruction( u
"xml"
_s, u
"version=\"1.0\" encoding=\"UTF-8\""
_s );
59
doc.appendChild( header );
60
61
QDomElement root = doc.createElement( u
"ServiceExceptionReport"
_s );
62
root.setAttribute( u
"version"
_s, mVersion );
63
root.setAttribute( u
"xmlns"
_s, u
"http://www.opengis.net/ogc"
_s );
64
doc.appendChild( root );
65
66
QDomElement elem = doc.createElement( u
"ServiceException"
_s );
67
elem.setAttribute( u
"code"
_s, mCode );
68
elem.appendChild( doc.createTextNode( mMessage ) );
69
root.appendChild( elem );
70
71
if
( !mLocator.isEmpty() )
72
{
73
elem.setAttribute( u
"locator"
_s, mLocator );
74
}
75
76
responseFormat = u
"text/xml; charset=utf-8"
_s;
77
return
doc.toByteArray();
78
}
QgsException::what
QString what() const
Definition
qgsexception.h:47
QgsException::QgsException
QgsException(const QString &message)
Constructor for QgsException, with the specified error message.
Definition
qgsexception.h:39
QgsOgcServiceException::locator
QString locator() const
Returns the locator.
Definition
qgsserverexception.h:99
QgsOgcServiceException::message
QString message() const
Returns the exception message.
Definition
qgsserverexception.h:93
QgsOgcServiceException::code
QString code() const
Returns the exception code.
Definition
qgsserverexception.h:96
QgsOgcServiceException::version
QString version() const
Returns the exception version.
Definition
qgsserverexception.h:102
QgsOgcServiceException::formatResponse
QByteArray formatResponse(QString &responseFormat) const override
Formats the exception for sending to client.
Definition
qgsserverexception.cpp:55
QgsOgcServiceException::QgsOgcServiceException
QgsOgcServiceException(const QString &code, const QString &message, const QString &locator=QString(), int responseCode=200, const QString &version=u"1.3.0"_s)
Construction.
Definition
qgsserverexception.cpp:47
QgsServerException::responseCode
int responseCode() const
Returns the return HTTP response code associated with this exception.
Definition
qgsserverexception.h:56
QgsServerException::formatResponse
virtual QByteArray formatResponse(QString &responseFormat) const
Formats the exception for sending to client.
Definition
qgsserverexception.cpp:31
QgsServerException::QgsServerException
QgsServerException(const QString &message, int responseCode=500)
Constructor.
Definition
qgsserverexception.cpp:26
qgsserverexception.h
Generated on
for QGIS API Documentation by
1.17.0