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

Error cleanup #117

Merged
merged 16 commits into from
Dec 20, 2021
Merged

Error cleanup #117

merged 16 commits into from
Dec 20, 2021

Conversation

eozturk1
Copy link
Contributor

  • Error names and descriptions updated
  • Unused or duplicate errors removed
  • Errors reused when needed

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 16, 2021
Copy link
Contributor

@slawlor slawlor left a comment

Choose a reason for hiding this comment

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

A lot cleaner for sure, thanks! We need to definitely address the unwrap() call before merging, but it's definitely close. Few minor things and we can close this out 👍

let (next_node_label, _) = hash_q
.pop()
.ok_or(AzksError::PopFromEmptyPriorityQueue(self.latest_epoch))?;
let (next_node_label, _) = hash_q.pop().unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

unwrap() is going to panic if it fails, rather than bubble up the error in an expected format. i.e. panic will terminate the app completely

Copy link
Contributor

@slawlor slawlor Dec 16, 2021

Choose a reason for hiding this comment

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

Also @Jasleen1 do we need the priority queue in the end here? Dropping it would let us also drop a crate dependency :)

EDIT yes we do, resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PopFromEmptyPriorityQueue implies the queue is empty but there is already an isEmpty check right before.

Could unwrap fail here?

Copy link
Contributor

Choose a reason for hiding this comment

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

So maybe we could just rewrite as a while let Ok((next_node_label, _)) = ... statement, an avoid the is empty check all together.

Copy link
Contributor

Choose a reason for hiding this comment

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

But yes I believe it can't fail, there's just better syntax to be used I think

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 like the while let approach, updated!

/// Error propogation
DirectoryErr(DirectoryError),
/// Error propogation
/// Error propagation
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like the comments, which are exported in the crate publicly could be cleaned up too over "error propogation"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are they not auto-synced? I can look into it if not.

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe they're hand typed... no? Maybe there's a rust feature I'm unaware of? Check with intellisense maybe and see what it says for a description on that case.

Copy link
Contributor Author

@eozturk1 eozturk1 Dec 20, 2021

Choose a reason for hiding this comment

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

cargo doc generates the docs and puts them into target/doc . We can specify a website that serves these docs. (See [documentation](https://doc.rust-lang.org/cargo/reference/manifest.html#the-documentation-field)).

Alternatively, if we don't, docs.rs automatically builds the docs and serves them. So doc updates in the code should be reflected in the published repo.

akd/src/errors.rs Outdated Show resolved Hide resolved
@eozturk1 eozturk1 merged commit 2ad6fe2 into facebook:main Dec 20, 2021
@eozturk1 eozturk1 deleted the error-cleanup branch December 20, 2021 17:55
@slawlor slawlor linked an issue Dec 20, 2021 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cleanup errors in the library
3 participants