Skip to content

Commit

Permalink
Manage LayerNotDefined exception
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed Mar 28, 2019
1 parent 5eca1f1 commit 2fc3da3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
12 changes: 8 additions & 4 deletions src/server/services/wms/qgswmsrendercontext.cpp
Expand Up @@ -395,8 +395,10 @@ void QgsWmsRenderContext::searchLayersToRenderSld()
}
else
{
throw QgsBadRequestException( QStringLiteral( "LayerNotDefined" ),
QStringLiteral( "Layer \"%1\" does not exist" ).arg( lname ) );
QgsWmsParameter param( QgsWmsParameter::LAYER );
param.mValue = lname;
throw QgsBadRequestException( QgsServiceException::OGC_LAYER_NOT_DEFINED,
param );
}
}
}
Expand Down Expand Up @@ -439,8 +441,10 @@ void QgsWmsRenderContext::searchLayersToRenderStyle()
}
else
{
throw QgsBadRequestException( QStringLiteral( "LayerNotDefined" ),
QStringLiteral( "Layer \"%1\" does not exist" ).arg( nickname ) );
QgsWmsParameter param( QgsWmsParameter::LAYER );
param.mValue = nickname;
throw QgsBadRequestException( QgsServiceException::OGC_LAYER_NOT_DEFINED,
param );
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/server/services/wms/qgswmsrenderer.cpp
Expand Up @@ -1309,8 +1309,11 @@ namespace QgsWms
}
if ( !validLayer && !mContext.isValidLayer( queryLayer ) && !mContext.isValidGroup( queryLayer ) )
{
QString msg = QObject::tr( "Layer '%1' not found" ).arg( queryLayer );
throw QgsBadRequestException( QStringLiteral( "LayerNotDefined" ), msg );
QgsWmsParameter param( QgsWmsParameter::LAYER );
param.mValue = queryLayer;
throw QgsBadRequestException( QgsServiceException::OGC_LAYER_NOT_DEFINED,
param );

}
else if ( ( validLayer && !queryableLayer ) || ( !validLayer && mContext.isValidGroup( queryLayer ) ) )
{
Expand Down
4 changes: 4 additions & 0 deletions src/server/services/wms/qgswmsserviceexception.h
Expand Up @@ -128,6 +128,10 @@ namespace QgsWms
break;
}
case OGC_LAYER_NOT_DEFINED:
{
message = QStringLiteral( "The layer '%1' does not exist." ).arg( parameter.toString() );
break;
}
case OGC_STYLE_NOT_DEFINED:
case OGC_LAYER_NOT_QUERYABLE:
case OGC_CURRENT_UPDATE_SEQUENCE:
Expand Down

0 comments on commit 2fc3da3

Please sign in to comment.