@@ -727,6 +727,7 @@ void QgsWmsProvider::tileReplyFinished()
727
727
if ( !status.isNull () && status.toInt () >= 400 )
728
728
{
729
729
QVariant phrase = reply->attribute ( QNetworkRequest::HttpReasonPhraseAttribute );
730
+ mErrorFormat = " text/plain" ;
730
731
mError = tr ( " tile request err %1: %2" ).arg ( status.toInt () ).arg ( phrase.toString () );
731
732
emit statusChanged ( mError );
732
733
@@ -808,6 +809,7 @@ void QgsWmsProvider::cacheReplyFinished()
808
809
if ( !status.isNull () && status.toInt () >= 400 )
809
810
{
810
811
QVariant phrase = cacheReply->attribute ( QNetworkRequest::HttpReasonPhraseAttribute );
812
+ mErrorFormat = " text/plain" ;
811
813
mError = tr ( " map request error %1: %2" ).arg ( status.toInt () ).arg ( phrase.toString () );
812
814
emit statusChanged ( mError );
813
815
@@ -865,7 +867,16 @@ bool QgsWmsProvider::retrieveServerCapabilities( bool forceRefresh )
865
867
866
868
if ( httpcapabilitiesresponse.isEmpty () )
867
869
{
868
- QgsDebugMsg ( " empty capabilities: " + mError );
870
+ mErrorFormat = " text/plain" ;
871
+ mError = tr ( " empty capabilities document" );
872
+ return false ;
873
+ }
874
+
875
+ if ( httpcapabilitiesresponse.startsWith ( " <html>" ) ||
876
+ httpcapabilitiesresponse.startsWith ( " <HTML>" ) )
877
+ {
878
+ mErrorFormat = " text/html" ;
879
+ mError = httpcapabilitiesresponse;
869
880
return false ;
870
881
}
871
882
@@ -919,11 +930,13 @@ void QgsWmsProvider::capabilitiesReplyFinished()
919
930
920
931
if ( httpcapabilitiesresponse.isEmpty () )
921
932
{
933
+ mErrorFormat = " text/plain" ;
922
934
mError = tr ( " empty of capabilities: %1" ).arg ( mCapabilitiesReply ->errorString () );
923
935
}
924
936
}
925
937
else
926
938
{
939
+ mErrorFormat = " text/plain" ;
927
940
mError = tr ( " Download of capabilities failed: %1" ).arg ( mCapabilitiesReply ->errorString () );
928
941
QgsDebugMsg ( " error: " + mError );
929
942
httpcapabilitiesresponse.clear ();
@@ -966,9 +979,12 @@ bool QgsWmsProvider::parseCapabilitiesDom( QByteArray const &xml, QgsWmsCapabili
966
979
if ( !contentSuccess )
967
980
{
968
981
mErrorCaption = tr ( " Dom Exception" );
969
- mError = tr ( " Could not get WMS capabilities: %1 at line %2 column %3\n " )
970
- .arg ( errorMsg ).arg ( errorLine ).arg ( errorColumn )
971
- + tr ( " This is probably due to an incorrect WMS Server URL." );
982
+ mErrorFormat = " text/plain" ;
983
+ mError = tr ( " Could not get WMS capabilities: %1 at line %2 column %3\n This is probably due to an incorrect WMS Server URL.\n Response was:\n\n %4" )
984
+ .arg ( errorMsg )
985
+ .arg ( errorLine )
986
+ .arg ( errorColumn )
987
+ .arg ( QString ( xml ) );
972
988
973
989
QgsLogger::debug ( " Dom Exception: " + mError );
974
990
@@ -986,10 +1002,12 @@ bool QgsWmsProvider::parseCapabilitiesDom( QByteArray const &xml, QgsWmsCapabili
986
1002
)
987
1003
{
988
1004
mErrorCaption = tr ( " Dom Exception" );
989
- mError = tr ( " Could not get WMS capabilities in the "
990
- " expected format (DTD): no %1 or %2 found\n " )
991
- .arg ( " WMS_Capabilities" ).arg ( " WMT_MS_Capabilities" )
992
- + tr ( " This is probably due to an incorrect WMS Server URL." );
1005
+ mErrorFormat = " text/plain" ;
1006
+ mError = tr ( " Could not get WMS capabilities in the expected format (DTD): no %1 or %2 found.\n This might be due to an incorrect WMS Server URL.\n Tag:%3\n Response was:\n %4" )
1007
+ .arg ( " WMS_Capabilities" )
1008
+ .arg ( " WMT_MS_Capabilities" )
1009
+ .arg ( docElem.tagName () )
1010
+ .arg ( QString ( xml ) );
993
1011
994
1012
QgsLogger::debug ( " Dom Exception: " + mError );
995
1013
@@ -1825,11 +1843,13 @@ bool QgsWmsProvider::parseServiceExceptionReportDom( QByteArray const & xml )
1825
1843
if ( !contentSuccess )
1826
1844
{
1827
1845
mErrorCaption = tr ( " Dom Exception" );
1828
- mError = tr ( " Could not get WMS Service Exception at %1: %2 at line %3 column %4" )
1846
+ mErrorFormat = " text/plain" ;
1847
+ mError = tr ( " Could not get WMS Service Exception at %1: %2 at line %3 column %4\n\n Response was:\n\n %4" )
1829
1848
.arg ( mBaseUrl )
1830
1849
.arg ( errorMsg )
1831
1850
.arg ( errorLine )
1832
- .arg ( errorColumn );
1851
+ .arg ( errorColumn )
1852
+ .arg ( QString ( xml ) );
1833
1853
1834
1854
QgsLogger::debug ( " Dom Exception: " + mError );
1835
1855
@@ -1875,10 +1895,12 @@ void QgsWmsProvider::parseServiceException( QDomElement const & e )
1875
1895
QString seCode = e.attribute ( " code" );
1876
1896
QString seText = e.text ();
1877
1897
1898
+ mErrorFormat = " text/plain" ;
1899
+
1878
1900
// set up friendly descriptions for the service exception
1879
1901
if ( seCode == " InvalidFormat" )
1880
1902
{
1881
- mError = tr ( " Request contains a Format not offered by the server." );
1903
+ mError = tr ( " Request contains a format not offered by the server." );
1882
1904
}
1883
1905
else if ( seCode == " InvalidCRS" )
1884
1906
{
@@ -2744,6 +2766,7 @@ void QgsWmsProvider::identifyReplyFinished()
2744
2766
if ( !status.isNull () && status.toInt () >= 400 )
2745
2767
{
2746
2768
QVariant phrase = mIdentifyReply ->attribute ( QNetworkRequest::HttpReasonPhraseAttribute );
2769
+ mErrorFormat = " text/plain" ;
2747
2770
mError = tr ( " map request error %1: %2" ).arg ( status.toInt () ).arg ( phrase.toString () );
2748
2771
emit statusChanged ( mError );
2749
2772
@@ -2781,6 +2804,10 @@ QString QgsWmsProvider::lastError()
2781
2804
return mError ;
2782
2805
}
2783
2806
2807
+ QString QgsWmsProvider::lastErrorFormat ()
2808
+ {
2809
+ return mErrorFormat ;
2810
+ }
2784
2811
2785
2812
QString QgsWmsProvider::name () const
2786
2813
{
0 commit comments