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;
89 int responseCode = 200,
const QString &version = QStringLiteral(
"1.3.0" ) );
92 QString
message()
const {
return mMessage; }
95 QString
code()
const {
return mCode; }
98 QString
locator()
const {
return mLocator; }
103 QByteArray formatResponse( QString &responseFormat
SIP_OUT )
const override;
151 QgsServerApiException(
const QString &code,
const QString &message,
const QString &mimeType = QStringLiteral(
"application/json" ),
int responseCode = 200 )
154 , mMimeType( mimeType )
160 responseFormat = mMimeType;
164 {
"code", mCode.toStdString() },
165 {
"description", what().toStdString() },
169 return QByteArray::fromStdString( data.dump() );
192 QgsServerApiInternalServerError(
const QString &message = QStringLiteral(
"Internal server error" ),
const QString &mimeType = QStringLiteral(
"application/json" ),
int responseCode = 500 )
193 :
QgsServerApiException( QStringLiteral(
"Internal server error" ), message, mimeType, responseCode )
213 QgsServerApiNotFoundError(
const QString &message,
const QString &mimeType = QStringLiteral(
"application/json" ),
int responseCode = 404 )
276 :
QgsServerApiException( QStringLiteral(
"Improperly configured error" ), message, mimeType, responseCode )
296 QgsServerApiNotImplementedException(
const QString &message = QStringLiteral(
"Requested method is not implemented" ),
const QString &mimeType = QStringLiteral(
"application/json" ),
int responseCode = 500 )
297 :
QgsServerApiException( QStringLiteral(
"Not implemented error" ), message, mimeType, responseCode )
316 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.