Skip to content

Commit

Permalink
- Moved the exception handling to OpenModelicaScriptingAPIQt.cpp. Jus…
Browse files Browse the repository at this point in the history
…t emit the signal with exception from there and show it in OMEdit.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@25444 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Apr 8, 2015
1 parent 267f1de commit cee9227
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions Compiler/Template/GenerateAPIFunctionsTpl.tpl
Expand Up @@ -148,6 +148,7 @@ template getQtInterfaceHeaders(list<DAE.Type> tys, String className)
signals:
void logCommand(QString command, QTime *commandTime);
void logResponse(QString response, QTime *responseTime);
void throwException(QString exception);
};
>>
end getQtInterfaceHeaders;
Expand Down Expand Up @@ -379,18 +380,22 @@ template getQtInterfaceFunc(String name, list<DAE.FuncArg> args, DAE.Type res, S
{
<%varDecl%>
MMC_TRY_TOP_INTERNAL()
QTime commandTime;
commandTime.start();
emit logCommand("<%replaceDotAndUnderscore(name)%>("+<%if intGt(listLength(args), 0) then commandArgs else 'QString("")'%>+")", &commandTime);
st = omc_OpenModelicaScriptingAPI_<%replaceDotAndUnderscore(name)%>(threadData, st<%inArgs%><%outArgs%>);
<%postCall%>
QString responseLog;
<%responseLog%>
emit logResponse(responseLog, &commandTime);
MMC_CATCH_TOP(throw std::runtime_error("<%replaceDotAndUnderscore(name)%> failed");)
try {
MMC_TRY_TOP_INTERNAL()
QTime commandTime;
commandTime.start();
emit logCommand("<%replaceDotAndUnderscore(name)%>("+<%if intGt(listLength(args), 0) then commandArgs else 'QString("")'%>+")", &commandTime);
st = omc_OpenModelicaScriptingAPI_<%replaceDotAndUnderscore(name)%>(threadData, st<%inArgs%><%outArgs%>);
<%postCall%>
QString responseLog;
<%responseLog%>
emit logResponse(responseLog, &commandTime);
MMC_CATCH_TOP()
} catch(std::exception &exception) {
emit throwException(QString("<%replaceDotAndUnderscore(name)%> failed. %1").arg(exception.what()));
}

<%if outArgs then "return result;"%>
}
Expand Down

0 comments on commit cee9227

Please sign in to comment.