Skip to content
Permalink
Browse files

Merge pull request #8715 from m-kuhn/expression_parser_error_fix

Fix expression parser error reporting
  • Loading branch information
m-kuhn committed Dec 20, 2018
2 parents bd87b35 + 06354ef commit 497a53b9fa4f023a5e0047232bceb0156392e3d4
Showing with 5 additions and 7 deletions.
  1. +5 −7 src/core/qgsexpressionparser.yy
@@ -239,21 +239,19 @@ expression:
QgsExpression::ParserError::ParserErrorType errorType = QgsExpression::ParserError::FunctionWrongArgs;
parser_ctx->currentErrorType = errorType;
QString expectedMessage;
if (func->params() == func->minParams())
if ( func->params() == func->minParams() )
{
expectedMessage = QString("Expected %2" ).arg( func->params());
expectedMessage = QStringLiteral( "Expected %1 but got %2." ).arg( QString::number( func->params() ), QString::number( $3->count() ) );
}
else
{
expectedMessage = QString("Expected between %2 and %4 max but got %3" ).arg( func->minParams(), func->params() );
expectedMessage = QStringLiteral( "Expected between %1 and %2 parameters but %3 were provided." ).arg( QString::number( func->minParams() ), QString::number( func->params() ), QString::number( $3->count() ) );
}
exp_error(&yyloc, parser_ctx, QString( "%1 function is called with wrong number of arguments."
"%2 but got %3" ).arg( QgsExpression::Functions()[fnIndex]->name() )
.arg( expectedMessage )
.arg( $3->count() ).toLocal8Bit().constData() );
exp_error(&yyloc, parser_ctx, QStringLiteral( "%1 function is called with wrong number of arguments. %2" ).arg( QgsExpression::Functions()[fnIndex]->name(), expectedMessage ).toUtf8().constData() );
delete $3;
YYERROR;
}

$$ = new QgsExpressionNodeFunction(fnIndex, $3);
addParserLocation(&@1, $$);
}

0 comments on commit 497a53b

Please sign in to comment.
You can’t perform that action at this time.