Skip to content

Commit

Permalink
explicit message error for WMS connection in the data source manager
Browse files Browse the repository at this point in the history
and avoid dupplicate text
  • Loading branch information
vcloarec authored and nyalldawson committed Feb 1, 2022
1 parent 46a28c6 commit 93c0510
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/providers/wms/qgswmscapabilities.cpp
Expand Up @@ -2490,7 +2490,18 @@ void QgsWmsCapabilitiesDownload::capabilitiesReplyFinished()
}
else
{
mError = tr( "Download of capabilities failed: %1" ).arg( mCapabilitiesReply->errorString() );
const QString contentType = mCapabilitiesReply->header( QNetworkRequest::ContentTypeHeader ).toString();

QString errorMessage;
if ( contentType.startsWith( QStringLiteral( "text/plain" ) ) )
errorMessage = mCapabilitiesReply->readAll();
else
errorMessage = mCapabilitiesReply->attribute( QNetworkRequest::HttpReasonPhraseAttribute ).toString();

if ( errorMessage.isEmpty() )
errorMessage = mCapabilitiesReply->errorString();

mError = tr( "Download of capabilities failed: %1" ).arg( errorMessage );
QgsMessageLog::logMessage( mError, tr( "WMS" ) );
mHttpCapabilitiesResponse.clear();
}
Expand Down
2 changes: 1 addition & 1 deletion src/providers/wms/qgswmssourceselect.cpp
Expand Up @@ -488,7 +488,7 @@ void QgsWMSSourceSelect::btnConnect_clicked()
QMessageBox::warning(
this,
tr( "WMS Provider" ),
tr( "Failed to download capabilities:\n" ) + capDownload.lastError()
capDownload.lastError()
);
return;
}
Expand Down

0 comments on commit 93c0510

Please sign in to comment.