-
Notifications
You must be signed in to change notification settings - Fork 12
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
Missing OSPModelDescription.xml causes logic_error to be thrown #782
Comments
Should then all instances of user misconfiguration lead to |
This is what I get for oversimplifying a complicated issue: difficult questions in return. :D It is especially complicated in the case of a library, because who is really the "user" here? Is it the end application user or the developer which develops something based on libcosim? The point is that a An error which occurs at runtime and could not have been anticipated, for example that a file gets deleted just as we were about to read it, or that a user misconfigured the software, should generally cause a It gets complicated, because in a low-level function you usually don't know where your input comes from. void processThis(const std::string& nonEmptyString) {
if (nonEmptyString.empty()) throw std::invalid_argument("I told you the string should be non-empty!");
// ...
} Here, the string could come from end-user input, but the function doesn't know this. Throwing a Anyway, in the case of osp_config load_osp_config(
const cosim::filesystem::path& configPath,
cosim::model_uri_resolver& resolver); It is completely fair to throw, say, |
And I take the answer to the question as "yes, please" 😀 Since I've been going over |
If a user tries to use OSP-specific features like variable group connections in their
OspSystemStructure.xml
, but the required*_OspModelDescription.xml
files are missing or not found, astd::logic_error
will be thrown during parsing of the system structure file.In other words, a user (runtime) error leads to an exception which signals a program (logic) error. Exceptions that represent runtime errors should always derive from
std::runtime_error
.The source of the exception is
get_emd()
insrc/cosim/osp_config_parser.cpp
, which throwsstd::out_of_range
, a subclass ofstd::logic_error
. I'd say this is a slight misuse of this exception class.Example of someone encountering this in the wild: open-simulation-platform/cosim-cli#115
The text was updated successfully, but these errors were encountered: