From 3fba5870446fd7f0d84688507b065b38e5de2ec0 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 1 Mar 2025 08:31:39 +0100 Subject: [PATCH] App: In ExpressionParser::parse add the failing expression text to the error message --- src/App/Expression.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/App/Expression.cpp b/src/App/Expression.cpp index d87d381dae..1afb5ec56e 100644 --- a/src/App/Expression.cpp +++ b/src/App/Expression.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -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.");