Skip to content

Add additional exception classes and introduce base exception #2996

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

Conversation

hannes-steffenhagen-diffblue
Copy link
Contributor

@hannes-steffenhagen-diffblue hannes-steffenhagen-diffblue commented Sep 19, 2018

This is part of the error handling cleanup work we are doing at the moment. It unifies the several exception types we introduced during that work into a single commit and addresses some requests for changes common to all of them at the same time.

This adds a number of new exception classes that are meant to be used to replace
unstructured throws in other parts of the code. The exception types have been
selected according to what we already determined we are going to need.

Further, this has a slight fix in the format for invalid_user_input_exceptiont
(it did previously not add a separator between the reason and the suggestion on
how to fix the error).

This also adds a cprover_exception_baset which is mean to avoid unnecessary
overhead when adding new exception types - without it, all driver programs would
have to updated to explicitly catch the new exception type whenever we introduce
one.

Also removes some dead code parse_options_baset (there was a final return that
cannot be reached because all ancestor statements are returns).

  • Each commit message has a non-empty body, explaining why the change was made.
  • My contribution is formatted in line with CODING_STANDARD.md.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

This adds a number of new exception classes that are meant to be used to replace
unstructured throws in other parts of the code. The exception types have been
selected according to what we already determined we are going to need.

Further, this has a slight fix in the format for invalid_user_input_exceptiont
(it did previously not add a separator between the reason and the suggestion on
how to fix the error).

This also adds a cprover_exception_baset which is mean to avoid unnecessary
overhead when adding new exception types - without it, all driver programs would
have to updated to explicitly catch the new exception type whenever we introduce
one.

Also removes some dead code parse_options_baset (there was a final return that
cannot be reached because all ancestor statements are returns).
@@ -71,12 +71,16 @@ int parse_options_baset::main()

return doit();
}
catch(invalid_user_input_exceptiont &e)
catch(const invalid_user_input_exceptiont &e)
{
std::cerr << e.what() << "\n";
return CPROVER_EXIT_USAGE_ERROR;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure whether or not we can merge this into the below case because this returns a different error code than the other exceptions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to be left as is, as it is in line with the previous code, which had a semantic distinction for the case when a user was passing a wrong argument (which afaik, is also important for automated tools or scripts using cbmc).

Copy link
Contributor

@NlightNFotis NlightNFotis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@danpoe danpoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passed Diffblue compatibility checks (cbmc commit: fb1be5d).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/85327320

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.

6 participants