20#include <QDomDocument>
23using namespace Qt::StringLiterals;
35 const QDomNode header = doc.createProcessingInstruction( u
"xml"_s, u
"version=\"1.0\" encoding=\"UTF-8\""_s );
36 doc.appendChild( header );
38 QDomElement root = doc.createElement( u
"ServerException"_s );
39 doc.appendChild( root );
40 root.appendChild( doc.createTextNode(
what() ) );
42 responseFormat = u
"text/xml; charset=utf-8"_s;
43 return doc.toByteArray();
60 const QDomNode header = doc.createProcessingInstruction( u
"xml"_s, u
"version=\"1.0\" encoding=\"UTF-8\""_s );
61 doc.appendChild( header );
63 QDomElement root = doc.createElement( u
"ServiceExceptionReport"_s );
64 root.setAttribute( u
"version"_s, mVersion );
65 root.setAttribute( u
"xmlns"_s, u
"http://www.opengis.net/ogc"_s );
66 doc.appendChild( root );
68 QDomElement elem = doc.createElement( u
"ServiceException"_s );
69 elem.setAttribute( u
"code"_s, mCode );
70 elem.appendChild( doc.createTextNode( mMessage ) );
71 root.appendChild( elem );
73 if ( !mLocator.isEmpty() )
75 elem.setAttribute( u
"locator"_s, mLocator );
78 responseFormat = u
"text/xml; charset=utf-8"_s;
79 return doc.toByteArray();
QgsException(const QString &message)
Constructor for QgsException, with the specified error message.
QString locator() const
Returns the locator.
QString message() const
Returns the exception message.
QString code() const
Returns the exception code.
QString version() const
Returns the exception version.
QByteArray formatResponse(QString &responseFormat) const override
Formats the exception for sending to client.
QgsOgcServiceException(const QString &code, const QString &message, const QString &locator=QString(), int responseCode=200, const QString &version=u"1.3.0"_s)
Construction.
int responseCode() const
Returns the return HTTP response code associated with this exception.
virtual QByteArray formatResponse(QString &responseFormat) const
Formats the exception for sending to client.
QgsServerException(const QString &message, int responseCode=500)
Constructor.