Skip to content

Commit 209b113

Browse files
committed
??? [OMCSessionZMQ] allways check for errors
needs additional changes to OMCSession* and ModelicaSystem
1 parent 3139c94 commit 209b113

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

OMPython/OMCSession.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,8 @@ def sendExpression(self, command, parsed=True):
556556
if p is not None:
557557
raise OMCSessionException("Process Exited, No connection with OMC. Create a new instance of OMCSessionZMQ!")
558558

559+
logger.debug("sendExpression(%r, %r)", command, parsed)
560+
559561
attempts = 0
560562
while True:
561563
try:
@@ -576,6 +578,14 @@ def sendExpression(self, command, parsed=True):
576578
return None
577579
else:
578580
result = self._omc.recv_string()
581+
582+
# allways check for error
583+
self._omc.send_string("getErrorString()", flags=zmq.NOBLOCK)
584+
error_raw = self._omc.recv_string()
585+
error_str = om_parser_typed(error_raw)
586+
if error_str:
587+
raise OMCSessionException(f"OM Error for 'sendExpression({command}, {parsed})': {error_str}")
588+
579589
if parsed is True:
580590
answer = om_parser_typed(result)
581591
return answer

0 commit comments

Comments
 (0)