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

Revise error type (copy from error_details branch) #34

Merged
merged 2 commits into from
Nov 9, 2017
Merged

Revise error type (copy from error_details branch) #34

merged 2 commits into from
Nov 9, 2017

Conversation

dhardy
Copy link
Owner

@dhardy dhardy commented Nov 8, 2017

This replaces #30; I plan to merge shortly

@nixpulvis
Copy link

I would make sure the ErrorKind docs make sense with this PR before merging.

ErrorKind::Transient | ErrorKind::NotReady => true,
_ => false,
}
}

Choose a reason for hiding this comment

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

I never know how nit picky to be. But I'd add a newline between end of functions and beginning of next function.

@@ -69,18 +68,11 @@ impl<R: Read> Rng for ReadRng<R> {
fn try_fill(&mut self, dest: &mut [u8]) -> Result<(), Error> {
if dest.len() == 0 { return Ok(()); }
// Use `std::io::read_exact`, which retries on `ErrorKind::Interrupted`.
self.reader.read_exact(dest).map_err(map_err)
self.reader.read_exact(dest).map_err(|err|
Error::new(ErrorKind::Unavailable, "ReadRng: read error", Some(err)))

Choose a reason for hiding this comment

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

This description doesn't really fit with the others.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I wasn't really sure what message to give here. Note that there should be a chained cause (though there's no guarantee it actually gets printed).

@pitdicker
Copy link

@nixpulvis
Copy link

Seems a lot like what has been in the works here. If I understand correctly, ErrorKind could be a context?

@dhardy
Copy link
Owner Author

dhardy commented Nov 8, 2017

Looks a nice library but nothing ground-breaking.

failure is no_std compatible, though some aspects of it (primarily the Error type) will not be available in no_std mode.

That's kind of the problem we had; unfortunately we need some Error type even with no_std. (Since allocators are part of the standard library and not necessarily available on embedded, we can't use Box, which means we need a Sized type, which basically comes down to an enum or a simple type.)

@dhardy dhardy merged commit bd60937 into master Nov 9, 2017
@dhardy dhardy deleted the err2 branch November 19, 2017 10:05
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.

None yet

3 participants