From 9ec86fad4e3e312f1cc7674bf4c6a8268dfcf201 Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Thu, 29 Aug 2019 10:13:23 +0800 Subject: [PATCH] App: improve exception message in PropertyExpressionEngine --- src/App/PropertyExpressionEngine.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/App/PropertyExpressionEngine.cpp b/src/App/PropertyExpressionEngine.cpp index 1e2ede8822..9cdc96ad36 100644 --- a/src/App/PropertyExpressionEngine.cpp +++ b/src/App/PropertyExpressionEngine.cpp @@ -550,10 +550,11 @@ DocumentObjectExecReturn *App::PropertyExpressionEngine::execute(ExecuteOption o throw Base::RuntimeError("Invalid property owner."); /* Set value of property */ + App::any value; try { // Evaluate expression std::unique_ptr e(expressions[*it].expression->eval()); - auto value = e->getValueAsAny(); + value = e->getValueAsAny(); if(option == ExecuteOnRestore && prop->testStatus(Property::EvalOnRestore)) { if(isAnyEqual(value, prop->getPathValue(*it))) continue; @@ -566,6 +567,15 @@ DocumentObjectExecReturn *App::PropertyExpressionEngine::execute(ExecuteOption o ss << e.what() << std::endl << "in property binding '" << prop->getName() << "'"; e.setMessage(ss.str()); throw; + }catch(std::bad_cast &e) { + std::ostringstream ss; + ss << "Invalid type '" << value.type().name() << "'"; + ss << "\nin property binding '" << prop->getName() << "'"; + throw Base::TypeError(ss.str().c_str()); + }catch(std::exception &e) { + std::ostringstream ss; + ss << e.what() << "\nin property binding '" << prop->getName() << "'"; + throw Base::RuntimeError(ss.str().c_str()); } } return DocumentObject::StdReturn;