mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-12 00:02:25 -04:00
Log exceptions according Info or Critical errors
This commit is contained in:
parent
6028b70f20
commit
eb72f16580
@ -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 );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user