Skip to content
This repository has been archived by the owner on May 20, 2019. It is now read-only.

Update error checking guidelines for clarity and to mention verify #10

Conversation

gavin-norman-sociomantic

verify did not exist when the guide was originally written.

@gavin-norman-sociomantic
Copy link
Author

Added extra commits fixing smaller issues.

Copy link
Contributor

Choose a reason for hiding this comment

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

Very nice!

3. `in` contracts (containing `assert`s) are fine to use in private methods/
functions, as the test coverage of such code can be guaranteed within the scope
of a module. For non-private methods/functions, test coverage cannot be
guaranteed, so `in` contracts should be avoided.

Choose a reason for hiding this comment

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

I would put a different emphasis - private functions can only be called through some public one, which should have required verify check on its own before calling any private one.

Choose a reason for hiding this comment

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

👍 that makes more sense. Updated.

@dylan-cromwell-sociomantic dylan-cromwell-sociomantic merged commit fd9ae79 into sociomantic-tsunami:master Aug 31, 2017
@dylan-cromwell-sociomantic
Copy link
Contributor

Merging because I trust your work here and it's obvious that a second set of eyes was on it with @mihails-strasuns-sociomantic's comment.

@gavin-norman-sociomantic
Copy link
Author

@dylan-cromwell-sociomantic for future reference, it'd be nice to wait for an approval review before merging.

@gavin-norman-sociomantic gavin-norman-sociomantic deleted the error-guide branch August 31, 2017 12:05
@dylan-cromwell-sociomantic
Copy link
Contributor

@gavin-norman-sociomantic apologies. Will do so for the future. Had thought the comment indicated this.

@mihails-strasuns-sociomantic
Copy link
Contributor

@dylan-cromwell-sociomantic we normally wait for review by two involved devs before merging and generally try to give some time so that anyone can jump in and comment :)

@dylan-cromwell-sociomantic
Copy link
Contributor

Yup, understood and makes perfect sense @mihails-strasuns-sociomantic! I will respect this going forward. Thanks for the heads up, you two!

Any actions to take now then?

@leandro-lucarella-sociomantic
Copy link
Contributor

No, it can be reviewed post-merge anyway and further PRs can be done if we find anything that needs fixing. I will review now for example :)

@dylan-cromwell-sociomantic
Copy link
Contributor

Aha, ok, thanks @leandro-lucarella-sociomantic!

Copy link
Contributor

Choose a reason for hiding this comment

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

Just a couple of minor comments.

load.
3. `in` contracts (containing `assert`s) should only be used on private methods/
functions which are called via a public API including `verify`/`enforce` checks.
`in` contracts on non-private methods/functions should be avoided.

Choose a reason for hiding this comment

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

I would clarify why (I assume is because of https://issues.dlang.org/show_bug.cgi?id=6856, but not 100% sure)

is being checked by a `verify` or `enforce` at some point in the code. If this
is not the case, convert the `assert` to a `verify` statement.

* All checks in `in` contracts should be converted to `verify` statements in the

Choose a reason for hiding this comment

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

I wonder if verify shouldn't just call assert() internally, so the program crashes in debug mode but let the application handle errors more gracefully in production builds.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants