Skip to content

Commit 86c0fe5

Browse files
committed
[ModelicaSystem] exception handling for sendExpression()
1 parent b411914 commit 86c0fe5

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__)
@@ -327,8 +327,14 @@ def buildModel(self, variableFilter=None):
327327
self.xmlparse()
328328

329329
def sendExpression(self, expr, parsed=True):
330-
logger.debug("sendExpression(%r, %r)", expr, parsed)
331-
return self.getconn.sendExpression(expr, parsed)
330+
try:
331+
retval = self.getconn.sendExpression(expr, parsed)
332+
except OMCSessionException as ex:
333+
raise ModelicaSystemError(f"Error executing {repr(expr)}") from ex
334+
335+
logger.debug(f"Result of executing {repr(expr)}: {repr(retval)}")
336+
337+
return retval
332338

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

0 commit comments

Comments
 (0)