Skip to content

Finish error handling #278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

syntron
Copy link
Contributor

@syntron syntron commented May 1, 2025

Finish update of error handling in OMSession.py and ModelicaSystem.py

Based on PR #277, #273 and #270

Changes

  • Always check for errors in sendExpression()
  • align logging - log data only once
  • cleanup

This was referenced May 1, 2025
@syntron syntron force-pushed the finish_error_handling branch from 5377e62 to 47cd01b Compare May 3, 2025 19:34
@syntron syntron mentioned this pull request May 6, 2025
@adeas31
Copy link
Member

adeas31 commented May 6, 2025

Rebase this one and see if you can use getMessagesStringInternal(). We should also check if expression is getErrorString() or getMessagesStringInternal() then we should not call it twice.

@syntron
Copy link
Contributor Author

syntron commented May 7, 2025

@adeas31 would it be possible to merge #281 and #282 before that? Both would merge in this order without problems even if not rebased.

This would simplify the merge as this PR is based on these two. Furthermore, I will be limited in time till mid of next week ...

@syntron
Copy link
Contributor Author

syntron commented May 7, 2025

@adeas31 do you have a simple way / an example to force an error? I would like to check how to evaluate the output of getMessagesStringInternal()

@adeas31
Copy link
Member

adeas31 commented May 7, 2025

Run the following script with omc,

loadString("model M Real foo = \"str\"; annotation (uses(Modelica(version=\"4.0.0\"))); end M;");
getMessagesStringInternal();
checkModel(M);
getMessagesStringInternal();

equivalent OMPython code is,

from OMPython import OMCSessionZMQ
omc = OMCSessionZMQ()
omc.sendExpression("model M Real foo = \"str\"; annotation (uses(Modelica(version=\"4.0.0\"))); end M;")
omc.sendExpression("getMessagesStringInternal()")
omc.sendExpression("checkModel(M)")
omc.sendExpression("getMessagesStringInternal()")

The first call to getMessagesStringInternal() gives the notificaitons caused by loading model M, the second call gives the error caused by calling checkModel(M).
Note. I haven't tried running the python code but I guess it will work.

You can also see how getMessagesStringInternal() is used in OMEdit here https://github.com/OpenModelica/OpenModelica/blob/master/OMEdit/OMEditLIB/OMC/OMCProxy.cpp#L611

@syntron syntron force-pushed the finish_error_handling branch 2 times, most recently from 8f6d05d to 31ef902 Compare May 8, 2025 20:26
@adeas31
Copy link
Member

adeas31 commented May 9, 2025

Let me know once its ready for review.

@syntron syntron force-pushed the finish_error_handling branch from 31ef902 to fe5f3e3 Compare May 9, 2025 19:03
@syntron
Copy link
Contributor Author

syntron commented May 9, 2025

Let me know once its ready for review.

@adeas31 all done including getMessagesStringInternal() in this PR

Please use the following order for review: PR #281, PR #282 (needs a simple conflict solution), PR #278

PR #279 is currently not updated as it would be on top of PR #278

Besides these, there are some smaller cleanups pending

@syntron syntron force-pushed the finish_error_handling branch from 08d1007 to 5d9b182 Compare May 12, 2025 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants