Skip to content
Permalink
Browse files

Log exceptions according Info or Critical errors

  • Loading branch information
pblottiere committed Mar 22, 2019
1 parent 6028b70 commit eb72f165801fe392c8b5b49b386ffc1546d09c71
@@ -347,11 +347,13 @@ void QgsServer::handleRequest( QgsServerRequest &request, QgsServerResponse &res
catch ( QgsServerException &ex )
{
responseDecorator.write( ex );
QgsMessageLog::logMessage( ex.formatResponse(), QStringLiteral( "Server" ), Qgis::Info );
}
catch ( QgsException &ex )
{
// Internal server error
response.sendError( 500, ex.what() );
QgsMessageLog::logMessage( ex.what(), QStringLiteral( "Server" ), Qgis::Critical );
}
}
// Terminate the response
@@ -27,6 +27,12 @@ QgsServerException::QgsServerException( const QString &message, int responseCode

}

QByteArray QgsServerException::formatResponse() const
{
QString responseFormat;
return formatResponse( responseFormat );
}

QByteArray QgsServerException::formatResponse( QString &responseFormat ) const
{
QDomDocument doc;
@@ -54,10 +54,12 @@ class SERVER_EXPORT QgsServerException
* \param responseFormat QString to store the content type of the response format.
* \returns QByteArray the fermatted response.
*
* The defaolt implementation return text/xml format.
* The default implementation returns text/xml format.
*/
virtual QByteArray formatResponse( QString &responseFormat SIP_OUT ) const;

QByteArray formatResponse() const;

private:
int mResponseCode;
};
@@ -80,7 +80,4 @@ void QgsServerResponse::write( const QgsServerException &ex )
setStatusCode( ex.responseCode() );
setHeader( "Content-Type", responseFormat );
write( ba );

// log exception on server side too
QgsMessageLog::logMessage( ba, QStringLiteral( "Server" ), Qgis::Critical );
}

0 comments on commit eb72f16

Please sign in to comment.
You can’t perform that action at this time.