Skip to content

Commit 859136b

Browse files
committed
- avoid crash on null value
1 parent 2c82606 commit 859136b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/copasijs.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ void setGroupFromJson(CCopasiParameterGroup* pGroup, ordered_json& settings)
9494
auto* param = pGroup->getParameter(el.key());
9595
if (param == NULL || dynamic_cast<CCopasiParameterGroup*>(param) != NULL)
9696
continue;
97+
if (el.value().empty())
98+
continue;
9799
auto type = param->getType();
98100
switch(type)
99101
{
@@ -1104,11 +1106,17 @@ std::string simulateJSON(ordered_json& yaml)
11041106
}
11051107
catch (CCopasiException &e)
11061108
{
1107-
return e.getMessage().getText().c_str();
1109+
ordered_json modelInfo;
1110+
modelInfo["status"] = "error";
1111+
modelInfo["messages"] = getMessages(0, "No Output");
1112+
return modelInfo.dump(2);
11081113
}
11091114
catch (std::exception &e)
11101115
{
1111-
return e.what();
1116+
ordered_json modelInfo;
1117+
modelInfo["status"] = "error";
1118+
modelInfo["messages"] = e.what();
1119+
return modelInfo.dump(2);
11121120
}
11131121
}
11141122

0 commit comments

Comments
 (0)