18 #ifndef QGSSERVEREXCEPTION_H 
   19 #define QGSSERVEREXCEPTION_H 
   26 #include "qgis_server.h" 
   28 #include "nlohmann/json.hpp" 
   31 using 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;
 
  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 )
 
  156       , mMimeType( mimeType )
 
  162       responseFormat = mMimeType;
 
  166           { 
"code", mCode.toStdString() },
 
  167           { 
"description", what().toStdString() },
 
  170       if ( responseFormat == QLatin1String( 
"application/json" ) )
 
  172         return QByteArray::fromStdString( data.dump() );
 
  174       else if ( responseFormat == QLatin1String( 
"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