App: In ExpressionParser::parse add the failing expression text to the error message

This commit is contained in:
wmayer
2025-03-01 08:31:39 +01:00
committed by Ladislav Michl
parent 2799aa2700
commit 3fba587044

View File

@@ -41,6 +41,7 @@
#include <sstream>
#include <stack>
#include <string>
#include <fmt/format.h>
#include <App/Application.h>
#include <App/DocumentObject.h>
@@ -3786,14 +3787,17 @@ Expression * App::ExpressionParser::parse(const App::DocumentObject *owner, cons
// run the parser
int result = ExpressionParser::ExpressionParser_yyparse ();
if (result != 0)
throw ParserError("Failed to parse expression.");
if (result != 0) {
throw ParserError(fmt::format("Failed to parse expression '{}'", buffer));
}
if (!ScanResult)
throw ParserError("Unknown error in expression");
if (!ScanResult) {
throw ParserError(fmt::format("Unknown error in expression '{}'", buffer));
}
if (valueExpression)
if (valueExpression) {
return ScanResult;
}
else {
delete ScanResult;
throw Expression::Exception("Expression can not evaluate to a value.");