18#ifndef QGSSERVEREXCEPTION_H
19#define QGSSERVEREXCEPTION_H
26#include "qgis_server.h"
28#include "nlohmann/json.hpp"
31using namespace nlohmann;
65 virtual QByteArray formatResponse( QString &responseFormat
SIP_OUT )
const;
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;
153 QgsServerApiException(
const QString &code,
const QString &message,
const QString &mimeType = QStringLiteral(
"application/json" ),
int responseCode = 200 )
156 , mMimeType( mimeType )
162 responseFormat = mMimeType;
166 {
"code", mCode.toStdString() },
167 {
"description", what().toStdString() },
171 return QByteArray::fromStdString( data.dump() );
194 QgsServerApiInternalServerError(
const QString &message = QStringLiteral(
"Internal server error" ),
const QString &mimeType = QStringLiteral(
"application/json" ),
int responseCode = 500 )
195 :
QgsServerApiException( QStringLiteral(
"Internal server error" ), message, mimeType, responseCode )
215 QgsServerApiNotFoundError(
const QString &message,
const QString &mimeType = QStringLiteral(
"application/json" ),
int responseCode = 404 )
278 :
QgsServerApiException( QStringLiteral(
"Improperly configured error" ), message, mimeType, responseCode )
298 QgsServerApiNotImplementedException(
const QString &message = QStringLiteral(
"Requested method is not implemented" ),
const QString &mimeType = QStringLiteral(
"application/json" ),
int responseCode = 500 )
299 :
QgsServerApiException( QStringLiteral(
"Not implemented error" ), message, mimeType, responseCode )
318 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.