Harmonizing exception handling in DPsim #539
georgii-tishenin
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
During a recent PR review @leonardocarreras raised a question: whether new code should throw standard C++ exceptions such as std::runtime_error / std::logic_error, or DPsim/CPS-specific exceptions?
At the moment, DPsim seems to use both approaches (or sometimes even none of them😅). Standard exceptions often provide useful custom messages, while some CPS/DPsim-specific exceptions are currently more like marker types and do not carry much context. Error logging is also not fully consistent: in some places errors are logged before throwing, while in others the exception is thrown without an explicit log entry.
This makes it unclear what style new code should follow and can make debugging harder, especially when errors surface through Python, examples, notebooks, or CI logs. I would like to start a discussion on what we want as the standard approach for DPsim. Questions for discussion:
Should DPsim prefer standard C++ exceptions, project-specific exceptions, or a hybrid?
Should every exception used in DPsim provide a useful what() message?
Where should exceptions be logged: at the throw site, at higher-level boundaries, or both?
Do std/CPS already provide needed categories of exceptions or should this be extended?
Should we document the agreed approach in the development guidelines?
All reactions