Skip to content
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

inventory builder could better distinguish runtime errors from API misuse #4672

Merged
merged 3 commits into from
Dec 12, 2023

Conversation

davepacheco
Copy link
Collaborator

The inventory builder has two forms of error reporting: found_error() is used to report things that are really part of the collection itself: a failure to collect some important information, or unexpected data, etc. Returned errors are used to signal to the caller that they've done something wrong. (These could as well be panics, except that the program state is not so wrong that it's dangerous to proceed.) This PR changes these to use simple newtypes. More could probably be done here (maybe in terms of making some of the CollectorBugs actual compile errors) but I think this is a useful step.

/// future readers can see what problems might make the collection
/// incomplete. By contrast, [`CollectorBug`]s are not reported and stored
/// this way.
pub fn found_error(&mut self, error: InventoryError) {
Copy link
Contributor

Choose a reason for hiding this comment

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

rustdoc is complaining about the doc links to private types; I'm surprised clippy isn't likewise complaining about InventoryError's presence here in a pub API. Maybe make this (and the error types) pub(crate)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for looking. I wound up exposing these instead. At this point I think it's useful to be able to fully use a CollectionBuilder from the outside (for tests, if nothing else).

@davepacheco davepacheco enabled auto-merge (squash) December 11, 2023 22:40
@davepacheco davepacheco merged commit c9bb9c1 into main Dec 12, 2023
20 of 21 checks passed
@davepacheco davepacheco deleted the dap/inventory-errors branch December 12, 2023 00:08
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