Skip to content
Permalink
Browse files

Merge pull request #9611 from pblottiere/server_log_exceptions

[server] log exceptions
  • Loading branch information
pblottiere committed Mar 25, 2019
2 parents 250c626 + b0ef62b commit daf53a1e089f63dfe7e25abd84494597963406d4
@@ -36,13 +36,13 @@ Constructor

virtual QByteArray formatResponse( QString &responseFormat /Out/ ) const;
%Docstring
Format the exception for sending to client
Formats the exception for sending to client


:return: - QByteArray the fermatted response.
:return: - QByteArray The formatted response.
- responseFormat: QString to store the content type of the response format.

The defaolt implementation return text/xml format.
The default implementation returns text/xml format.
%End

};
@@ -347,11 +347,14 @@ void QgsServer::handleRequest( QgsServerRequest &request, QgsServerResponse &res
catch ( QgsServerException &ex )
{
responseDecorator.write( ex );
QString format;
QgsMessageLog::logMessage( ex.formatResponse( format ), QStringLiteral( "Server" ), Qgis::Info );
}
catch ( QgsException &ex )
{
// Internal server error
response.sendError( 500, ex.what() );
response.sendError( 500, QStringLiteral( "Internal Server Error" ) );
QgsMessageLog::logMessage( ex.what(), QStringLiteral( "Server" ), Qgis::Critical );
}
}
// Terminate the response
@@ -49,12 +49,12 @@ class SERVER_EXPORT QgsServerException
int responseCode() const { return mResponseCode; }

/**
* Format the exception for sending to client
* Formats the exception for sending to client
*
* \param responseFormat QString to store the content type of the response format.
* \returns QByteArray the fermatted response.
* \returns QByteArray The formatted response.
*
* The defaolt implementation return text/xml format.
* The default implementation returns text/xml format.
*/
virtual QByteArray formatResponse( QString &responseFormat SIP_OUT ) const;

@@ -27,8 +27,6 @@ void QgsServerResponse::write( const QString &data )
QIODevice *iodev = io();
if ( iodev )
{
//QTextStream stream( iodev );
//stream << data;
iodev->write( data.toUtf8() );
}
else
@@ -37,7 +35,6 @@ void QgsServerResponse::write( const QString &data )
}
}


qint64 QgsServerResponse::write( const QByteArray &byteArray )
{
QIODevice *iodev = io();
@@ -48,7 +45,6 @@ qint64 QgsServerResponse::write( const QByteArray &byteArray )
return 0;
}


qint64 QgsServerResponse::write( const char *data, qint64 maxsize )
{
QIODevice *iodev = io();
@@ -85,4 +81,3 @@ void QgsServerResponse::write( const QgsServerException &ex )
setHeader( "Content-Type", responseFormat );
write( ba );
}

0 comments on commit daf53a1

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