Skip to content

Commit

Permalink
App: improve exception message in PropertyExpressionEngine
Browse files Browse the repository at this point in the history
  • Loading branch information
realthunder authored and wwmayer committed Aug 30, 2019
1 parent f7d416d commit 9ec86fa
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/App/PropertyExpressionEngine.cpp
Expand Up @@ -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<Expression> 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;
Expand All @@ -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;
Expand Down

0 comments on commit 9ec86fa

Please sign in to comment.