18 #ifndef QGSSERVEREXCEPTION_H 19 #define QGSSERVEREXCEPTION_H 26 #include "qgis_server.h" 28 #include "nlohmann/json.hpp" 45 class SERVER_EXPORT QgsServerException
50 QgsServerException(
const QString &message,
int responseCode = 500 );
65 virtual QByteArray formatResponse( QString &responseFormat
SIP_OUT )
const;
85 class SERVER_EXPORT QgsOgcServiceException
90 QgsOgcServiceException(
const QString &code,
const QString &message,
const QString &locator = QString(),
91 int responseCode = 200,
const QString &version = QStringLiteral(
"1.3.0" ) );
94 QString
message()
const {
return mMessage; }
97 QString
code()
const {
return mCode; }
105 QByteArray formatResponse( QString &responseFormat
SIP_OUT )
const override;
132 : QgsOgcServiceException( code, message, locator, 400 )
137 #ifndef SIP_RUN // No API exceptions for SIP, see python/server/qgsserverexception.sip 153 QgsServerApiException(
const QString &code,
const QString &message,
const QString &mimeType = QStringLiteral(
"application/json" ),
int responseCode = 200 )
154 : QgsServerException( message, responseCode )
156 , mMimeType( mimeType )
162 responseFormat = mMimeType;
166 {
"code", mCode.toStdString() },
167 {
"description", what().toStdString() },
170 if ( responseFormat == QStringLiteral(
"application/json" ) )
172 return QByteArray::fromStdString( data.dump() );
174 else if ( responseFormat == QStringLiteral(
"text/html" ) )
177 return QByteArray::fromStdString( data.dump() );
182 return QByteArray::fromStdString( data.dump() );
206 QgsServerApiInternalServerError(
const QString &message = QStringLiteral(
"Internal server error" ),
const QString &mimeType = QStringLiteral(
"application/json" ),
int responseCode = 500 )
207 :
QgsServerApiException( QStringLiteral(
"Internal server error" ), message, mimeType, responseCode )
227 QgsServerApiNotFoundError(
const QString &message,
const QString &mimeType = QStringLiteral(
"application/json" ),
int responseCode = 404 )
290 :
QgsServerApiException( QStringLiteral(
"Improperly configured error" ), message, mimeType, responseCode )
310 QgsServerApiNotImplementedException(
const QString &message = QStringLiteral(
"Requested method is not implemented" ),
const QString &mimeType = QStringLiteral(
"application/json" ),
int responseCode = 500 )
311 :
QgsServerApiException( QStringLiteral(
"Not implemented error" ), message, mimeType, responseCode )
330 QgsServerApiInvalidMimeTypeException(
const QString &message = QStringLiteral(
"The Accept header submitted in the request did not support any of the media types supported by the server for the requested resource" ),
const QString &mimeType = QStringLiteral(
"application/json" ),
int responseCode = 406 )
335 #endif // no API exceptions for SIP QgsServerApiInvalidMimeTypeException(const QString &message=QStringLiteral("The Accept header submitted in the request did not support any of the media types supported by the server for the requested resource"), const QString &mimeType=QStringLiteral("application/json"), int responseCode=406)
Construction.
Not found error API exception.
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.
QString message() const
Returns the exception message.
Internal server error API exception.
QgsServerApiPermissionDeniedException(const QString &message, const QString &mimeType=QStringLiteral("application/json"), int responseCode=403)
Construction.
Exception base class for API exceptions.
Forbidden (permission denied) 403.
QgsServerApiException(const QString &code, const QString &message, const QString &mimeType=QStringLiteral("application/json"), int responseCode=200)
Construction.
this method is not yet implemented
QString version() const
Returns the exception version.
QString locator() const
Returns the locator.
QgsServerApiBadRequestException(const QString &message, const QString &mimeType=QStringLiteral("application/json"), int responseCode=400)
Construction.
Exception base class for server exceptions.
Bad request error API exception.
QByteArray formatResponse(QString &responseFormat) const override
Formats the exception for sending to client.
QString code() const
Returns the exception code.
QgsServerApiNotImplementedException(const QString &message=QStringLiteral("Requested method is not implemented"), const QString &mimeType=QStringLiteral("application/json"), int responseCode=500)
Construction.
QgsServerApiNotFoundError(const QString &message, const QString &mimeType=QStringLiteral("application/json"), int responseCode=404)
Construction.
the client sent an invalid mime type in the "Accept" header
Defines a QGIS exception class.
QgsServerApiInternalServerError(const QString &message=QStringLiteral("Internal server error"), const QString &mimeType=QStringLiteral("application/json"), int responseCode=500)
Construction.