Skip to content

Commit

Permalink
Use reply content as an error string if it is plain text
Browse files Browse the repository at this point in the history
  • Loading branch information
uclaros authored and nyalldawson committed Feb 6, 2025
1 parent 2f6bcb3 commit c004c66
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/core/stac/qgsstaccontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ void QgsStacController::handleStacObjectReply()

if ( reply->error() != QNetworkReply::NoError )
{
emit finishedStacObjectRequest( requestId, reply->errorString() );
const QString contentType = reply->header( QNetworkRequest::ContentTypeHeader ).toString();
const QString errorMessage = contentType.startsWith( QLatin1String( "text/plain" ) ) ? reply->readAll() : reply->errorString();

emit finishedStacObjectRequest( requestId, errorMessage );
reply->deleteLater();
mReplies.removeOne( reply );
return;
Expand Down Expand Up @@ -155,7 +158,10 @@ void QgsStacController::handleItemCollectionReply()

if ( reply->error() != QNetworkReply::NoError )
{
emit finishedItemCollectionRequest( requestId, reply->errorString() );
const QString contentType = reply->header( QNetworkRequest::ContentTypeHeader ).toString();
const QString errorMessage = contentType.startsWith( QLatin1String( "text/plain" ) ) ? reply->readAll() : reply->errorString();

emit finishedItemCollectionRequest( requestId, errorMessage );
reply->deleteLater();
mReplies.removeOne( reply );
return;
Expand Down Expand Up @@ -184,7 +190,10 @@ void QgsStacController::handleCollectionsReply()

if ( reply->error() != QNetworkReply::NoError )
{
emit finishedCollectionsRequest( requestId, reply->errorString() );
const QString contentType = reply->header( QNetworkRequest::ContentTypeHeader ).toString();
const QString errorMessage = contentType.startsWith( QLatin1String( "text/plain" ) ) ? reply->readAll() : reply->errorString();

emit finishedCollectionsRequest( requestId, errorMessage );
reply->deleteLater();
mReplies.removeOne( reply );
return;
Expand Down

0 comments on commit c004c66

Please sign in to comment.