|
18 | 18 |
|
19 | 19 | from OMPython.model_execution import ( |
20 | 20 | ModelExecutionCmd, |
| 21 | + ModelExecutionException, |
21 | 22 | ) |
22 | 23 | from OMPython.om_session_abc import ( |
23 | 24 | OMPathABC, |
@@ -199,7 +200,10 @@ def check_model_executable(self): |
199 | 200 | # ... by running it - output help for command help |
200 | 201 | om_cmd.arg_set(key="help", val="help") |
201 | 202 | cmd_definition = om_cmd.definition() |
202 | | - returncode = cmd_definition.run() |
| 203 | + try: |
| 204 | + returncode = cmd_definition.run() |
| 205 | + except ModelExecutionException as exc: |
| 206 | + raise ModelicaSystemError(f"Cannot execute model: {exc}") from exc |
203 | 207 | if returncode != 0: |
204 | 208 | raise ModelicaSystemError("Model executable not working!") |
205 | 209 |
|
@@ -730,7 +734,10 @@ def simulate( |
730 | 734 | self._result_file.unlink() |
731 | 735 | # ... run simulation ... |
732 | 736 | cmd_definition = om_cmd.definition() |
733 | | - returncode = cmd_definition.run() |
| 737 | + try: |
| 738 | + returncode = cmd_definition.run() |
| 739 | + except ModelExecutionException as exc: |
| 740 | + raise ModelicaSystemError(f"Cannot execute model: {exc}") from exc |
734 | 741 | # and check returncode *AND* resultfile |
735 | 742 | if returncode != 0 and self._result_file.is_file(): |
736 | 743 | # check for an empty (=> 0B) result file which indicates a crash of the model executable |
@@ -1173,7 +1180,10 @@ def linearize( |
1173 | 1180 | linear_file.unlink(missing_ok=True) |
1174 | 1181 |
|
1175 | 1182 | cmd_definition = om_cmd.definition() |
1176 | | - returncode = cmd_definition.run() |
| 1183 | + try: |
| 1184 | + returncode = cmd_definition.run() |
| 1185 | + except ModelExecutionException as exc: |
| 1186 | + raise ModelicaSystemError(f"Cannot execute model: {exc}") from exc |
1177 | 1187 | if returncode != 0: |
1178 | 1188 | raise ModelicaSystemError(f"Linearize failed with return code: {returncode}") |
1179 | 1189 | if not linear_file.is_file(): |
|
0 commit comments