mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-03 00:02:25 -05:00
Auto format message for invalid parameter value
This commit is contained in:
parent
bdda3715c4
commit
0f0438f675
@ -278,14 +278,14 @@ namespace QgsWms
|
||||
QgsPrintLayout *sourceLayout( dynamic_cast<QgsPrintLayout *>( lManager->layoutByName( templateName ) ) );
|
||||
if ( !sourceLayout )
|
||||
{
|
||||
throw QgsBadRequestException( QStringLiteral( "InvalidTemplate" ),
|
||||
QStringLiteral( "Template '%1' is not known" ).arg( templateName ) );
|
||||
throw QgsBadRequestException( QgsServiceException::QGIS_INVALID_PARAMETER_VALUE,
|
||||
QgsWmsParameter::TEMPLATE );
|
||||
}
|
||||
|
||||
// Check that layout has at least one page
|
||||
if ( sourceLayout->pageCollection()->pageCount() < 1 )
|
||||
{
|
||||
throw QgsBadRequestException( QStringLiteral( "InvalidTemplate" ),
|
||||
throw QgsBadRequestException( QgsServiceException::QGIS_INVALID_PARAMETER_VALUE,
|
||||
QStringLiteral( "Template '%1' has no pages" ).arg( templateName ) );
|
||||
}
|
||||
|
||||
@ -747,7 +747,7 @@ namespace QgsWms
|
||||
// check size
|
||||
if ( !checkMaximumWidthHeight() )
|
||||
{
|
||||
throw QgsBadRequestException( QStringLiteral( "Size error" ),
|
||||
throw QgsBadRequestException( QgsServiceException::QGIS_INVALID_PARAMETER_VALUE,
|
||||
QStringLiteral( "The requested map size is too large" ) );
|
||||
}
|
||||
|
||||
@ -954,8 +954,8 @@ namespace QgsWms
|
||||
QgsRectangle mapExtent = mWmsParameters.bboxAsRectangle();
|
||||
if ( !mWmsParameters.bbox().isEmpty() && mapExtent.isEmpty() )
|
||||
{
|
||||
throw QgsBadRequestException( QStringLiteral( "InvalidParameterValue" ),
|
||||
QStringLiteral( "Invalid BBOX parameter" ) );
|
||||
throw QgsBadRequestException( QgsServiceException::QGIS_INVALID_PARAMETER_VALUE,
|
||||
QgsWmsParameter::BBOX );
|
||||
}
|
||||
|
||||
QString crs = mWmsParameters.crs();
|
||||
@ -983,9 +983,15 @@ namespace QgsWms
|
||||
}
|
||||
}
|
||||
|
||||
if ( width <= 0 || height <= 0 )
|
||||
if ( width <= 0 )
|
||||
{
|
||||
throw QgsException( QStringLiteral( "createImage: Invalid width / height parameters" ) );
|
||||
throw QgsBadRequestException( QgsServiceException::QGIS_INVALID_PARAMETER_VALUE,
|
||||
QgsWmsParameter::WIDTH );
|
||||
}
|
||||
else if ( height <= 0 )
|
||||
{
|
||||
throw QgsBadRequestException( QgsServiceException::QGIS_INVALID_PARAMETER_VALUE,
|
||||
QgsWmsParameter::HEIGHT );
|
||||
}
|
||||
|
||||
std::unique_ptr<QImage> image;
|
||||
@ -1032,7 +1038,8 @@ namespace QgsWms
|
||||
QgsRectangle mapExtent = mWmsParameters.bboxAsRectangle();
|
||||
if ( !mWmsParameters.bbox().isEmpty() && mapExtent.isEmpty() )
|
||||
{
|
||||
throw QgsBadRequestException( QStringLiteral( "InvalidParameterValue" ), QStringLiteral( "Invalid BBOX parameter" ) );
|
||||
throw QgsBadRequestException( QgsServiceException::QGIS_INVALID_PARAMETER_VALUE,
|
||||
QgsWmsParameter::BBOX );
|
||||
}
|
||||
|
||||
QString crs = mWmsParameters.crs();
|
||||
@ -2806,12 +2813,12 @@ namespace QgsWms
|
||||
contentBasedLegend = true;
|
||||
contentBasedLegendExtent = mWmsParameters.bboxAsRectangle();
|
||||
if ( contentBasedLegendExtent.isEmpty() )
|
||||
throw QgsBadRequestException( QStringLiteral( "InvalidParameterValue" ),
|
||||
QStringLiteral( "Invalid BBOX parameter" ) );
|
||||
throw QgsBadRequestException( QgsServiceException::QGIS_INVALID_PARAMETER_VALUE,
|
||||
QgsWmsParameter::BBOX );
|
||||
|
||||
if ( !mWmsParameters.rule().isEmpty() )
|
||||
throw QgsBadRequestException( QStringLiteral( "InvalidParameterValue" ),
|
||||
QStringLiteral( "BBOX parameter cannot be combined with RULE" ) );
|
||||
throw QgsBadRequestException( QgsServiceException::QGIS_INVALID_PARAMETER_VALUE,
|
||||
QStringLiteral( "BBOX parameter cannot be combined with RULE." ) );
|
||||
}
|
||||
|
||||
// build layer tree
|
||||
|
@ -108,6 +108,11 @@ namespace QgsWms
|
||||
message = QStringLiteral( "The %1 parameter is missing." ).arg( name );
|
||||
break;
|
||||
}
|
||||
case QGIS_INVALID_PARAMETER_VALUE:
|
||||
{
|
||||
message = QStringLiteral( "The %1 parameter is invalid." ).arg( name );
|
||||
break;
|
||||
}
|
||||
case OGC_INVALID_FORMAT:
|
||||
case OGC_INVALID_SRS:
|
||||
case OGC_LAYER_NOT_DEFINED:
|
||||
@ -119,7 +124,6 @@ namespace QgsWms
|
||||
case OGC_INVALID_DIMENSION_VALUE:
|
||||
case OGC_INVALID_CRS:
|
||||
case OGC_OPERATION_NOT_SUPPORTED:
|
||||
case QGIS_INVALID_PARAMETER_VALUE:
|
||||
case QGIS_ERROR:
|
||||
{
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user