Skip to content

Commit f2af554

Browse files
committed
[ModelicaSystem] exception handling for sendExpression()
1 parent a8d5bac commit f2af554

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

OMPython/ModelicaSystem.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
from dataclasses import dataclass
4747
from typing import Optional
4848

49-
from OMPython.OMCSession import OMCSessionZMQ
49+
from OMPython.OMCSession import OMCSessionZMQ, OMCSessionException
5050

5151
# define logger using the current module name as ID
5252
logger = logging.getLogger(__name__)
@@ -332,8 +332,14 @@ def buildModel(self, variableFilter=None):
332332
self.xmlparse()
333333

334334
def sendExpression(self, expr, parsed=True):
335-
logger.debug("sendExpression(%r, %r)", expr, parsed)
336-
return self.getconn.sendExpression(expr, parsed)
335+
try:
336+
retval = self.getconn.sendExpression(expr, parsed)
337+
except OMCSessionException as ex:
338+
raise ModelicaSystemError(f"Error executing {repr(expr)}") from ex
339+
340+
logger.debug(f"Result of executing {repr(expr)}: {repr(retval)}")
341+
342+
return retval
337343

338344
# request to OMC
339345
def requestApi(self, apiName, entity=None, properties=None): # 2

0 commit comments

Comments
 (0)