20#include <QDomDocument>
25 , mResponseCode( responseCode )
33 const QDomNode header = doc.createProcessingInstruction( QStringLiteral(
"xml" ), QStringLiteral(
"version=\"1.0\" encoding=\"UTF-8\"" ) );
34 doc.appendChild( header );
36 QDomElement root = doc.createElement( QStringLiteral(
"ServerException" ) );
37 doc.appendChild( root );
38 root.appendChild( doc.createTextNode(
what() ) );
40 responseFormat = QStringLiteral(
"text/xml; charset=utf-8" );
41 return doc.toByteArray();
47 int responseCode,
const QString &version )
59 const QDomNode header = doc.createProcessingInstruction( QStringLiteral(
"xml" ), QStringLiteral(
"version=\"1.0\" encoding=\"UTF-8\"" ) );
60 doc.appendChild( header );
62 QDomElement root = doc.createElement( QStringLiteral(
"ServiceExceptionReport" ) );
63 root.setAttribute( QStringLiteral(
"version" ), mVersion );
64 root.setAttribute( QStringLiteral(
"xmlns" ), QStringLiteral(
"http://www.opengis.net/ogc" ) );
65 doc.appendChild( root );
67 QDomElement elem = doc.createElement( QStringLiteral(
"ServiceException" ) );
68 elem.setAttribute( QStringLiteral(
"code" ), mCode );
69 elem.appendChild( doc.createTextNode( mMessage ) );
70 root.appendChild( elem );
72 if ( ! mLocator.isEmpty() )
74 elem.setAttribute( QStringLiteral(
"locator" ), mLocator );
77 responseFormat = QStringLiteral(
"text/xml; charset=utf-8" );
78 return doc.toByteArray();
Defines a QGIS exception class.
QgsOgcServiceException(const QString &code, const QString &message, const QString &locator=QString(), int responseCode=200, const QString &version=QStringLiteral("1.3.0"))
Construction.
QByteArray formatResponse(QString &responseFormat) const override
Formats the exception for sending to client.
Exception base class for server exceptions.
virtual QByteArray formatResponse(QString &responseFormat) const
Formats the exception for sending to client.
QgsServerException(const QString &message, int responseCode=500)
Constructor.