Skip to content

Commit 2fc3da3

Browse files
committedMar 28, 2019
Manage LayerNotDefined exception
1 parent 5eca1f1 commit 2fc3da3

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed
 

‎src/server/services/wms/qgswmsrendercontext.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,10 @@ void QgsWmsRenderContext::searchLayersToRenderSld()
395395
}
396396
else
397397
{
398-
throw QgsBadRequestException( QStringLiteral( "LayerNotDefined" ),
399-
QStringLiteral( "Layer \"%1\" does not exist" ).arg( lname ) );
398+
QgsWmsParameter param( QgsWmsParameter::LAYER );
399+
param.mValue = lname;
400+
throw QgsBadRequestException( QgsServiceException::OGC_LAYER_NOT_DEFINED,
401+
param );
400402
}
401403
}
402404
}
@@ -439,8 +441,10 @@ void QgsWmsRenderContext::searchLayersToRenderStyle()
439441
}
440442
else
441443
{
442-
throw QgsBadRequestException( QStringLiteral( "LayerNotDefined" ),
443-
QStringLiteral( "Layer \"%1\" does not exist" ).arg( nickname ) );
444+
QgsWmsParameter param( QgsWmsParameter::LAYER );
445+
param.mValue = nickname;
446+
throw QgsBadRequestException( QgsServiceException::OGC_LAYER_NOT_DEFINED,
447+
param );
444448
}
445449
}
446450
}

‎src/server/services/wms/qgswmsrenderer.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,8 +1309,11 @@ namespace QgsWms
13091309
}
13101310
if ( !validLayer && !mContext.isValidLayer( queryLayer ) && !mContext.isValidGroup( queryLayer ) )
13111311
{
1312-
QString msg = QObject::tr( "Layer '%1' not found" ).arg( queryLayer );
1313-
throw QgsBadRequestException( QStringLiteral( "LayerNotDefined" ), msg );
1312+
QgsWmsParameter param( QgsWmsParameter::LAYER );
1313+
param.mValue = queryLayer;
1314+
throw QgsBadRequestException( QgsServiceException::OGC_LAYER_NOT_DEFINED,
1315+
param );
1316+
13141317
}
13151318
else if ( ( validLayer && !queryableLayer ) || ( !validLayer && mContext.isValidGroup( queryLayer ) ) )
13161319
{

‎src/server/services/wms/qgswmsserviceexception.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ namespace QgsWms
128128
break;
129129
}
130130
case OGC_LAYER_NOT_DEFINED:
131+
{
132+
message = QStringLiteral( "The layer '%1' does not exist." ).arg( parameter.toString() );
133+
break;
134+
}
131135
case OGC_STYLE_NOT_DEFINED:
132136
case OGC_LAYER_NOT_QUERYABLE:
133137
case OGC_CURRENT_UPDATE_SEQUENCE:

0 commit comments

Comments
 (0)
Please sign in to comment.