18#ifndef QGSSERVEREXCEPTION_H
19#define QGSSERVEREXCEPTION_H
26#include "qgis_server.h"
28#include "nlohmann/json.hpp"
31using namespace nlohmann;
64 virtual QByteArray formatResponse( QString &responseFormat
SIP_OUT )
const;
88 QgsOgcServiceException(
const QString &code,
const QString &message,
const QString &locator = QString(),
int responseCode = 200,
const QString &version = QStringLiteral(
"1.3.0" ) );
91 QString
message()
const {
return mMessage; }
94 QString
code()
const {
return mCode; }
97 QString
locator()
const {
return mLocator; }
102 QByteArray formatResponse( QString &responseFormat
SIP_OUT )
const override;
149 QgsServerApiException(
const QString &code,
const QString &message,
const QString &mimeType = QStringLiteral(
"application/json" ),
int responseCode = 200 )
152 , mMimeType( mimeType )
158 responseFormat = mMimeType;
161 {
"code", mCode.toStdString() },
162 {
"description", what().toStdString() },
166 return QByteArray::fromStdString( data.dump() );
189 QgsServerApiInternalServerError(
const QString &message = QStringLiteral(
"Internal server error" ),
const QString &mimeType = QStringLiteral(
"application/json" ),
int responseCode = 500 )
190 :
QgsServerApiException( QStringLiteral(
"Internal server error" ), message, mimeType, responseCode )
210 QgsServerApiNotFoundError(
const QString &message,
const QString &mimeType = QStringLiteral(
"application/json" ),
int responseCode = 404 )
273 :
QgsServerApiException( QStringLiteral(
"Improperly configured error" ), message, mimeType, responseCode )
293 QgsServerApiNotImplementedException(
const QString &message = QStringLiteral(
"Requested method is not implemented" ),
const QString &mimeType = QStringLiteral(
"application/json" ),
int responseCode = 500 )
294 :
QgsServerApiException( QStringLiteral(
"Not implemented error" ), message, mimeType, responseCode )
313 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 )
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).
Defines a QGIS exception class.
Exception base class for service exceptions.
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.
Bad request error API exception.
QgsServerApiBadRequestException(const QString &message, const QString &mimeType=QStringLiteral("application/json"), int responseCode=400)
Construction.
Exception base class for API exceptions.
QgsServerApiException(const QString &code, const QString &message, const QString &mimeType=QStringLiteral("application/json"), int responseCode=200)
Construction.
QByteArray formatResponse(QString &responseFormat) const override
Formats the exception for sending to client.
Internal server error API exception.
QgsServerApiInternalServerError(const QString &message=QStringLiteral("Internal server error"), const QString &mimeType=QStringLiteral("application/json"), int responseCode=500)
Construction.
the client sent an invalid mime type in the "Accept" header
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.
QgsServerApiNotFoundError(const QString &message, const QString &mimeType=QStringLiteral("application/json"), int responseCode=404)
Construction.
this method is not yet implemented
QgsServerApiNotImplementedException(const QString &message=QStringLiteral("Requested method is not implemented"), const QString &mimeType=QStringLiteral("application/json"), int responseCode=500)
Construction.
Forbidden (permission denied) 403.
QgsServerApiPermissionDeniedException(const QString &message, const QString &mimeType=QStringLiteral("application/json"), int responseCode=403)
Construction.
Exception base class for server exceptions.