-
Notifications
You must be signed in to change notification settings - Fork 182
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
rand_core and error types #3
Comments
I would prefer to use a simple (non-exhaustive) error enum without any associated explicit error codes. |
If we can translate the source error codes appropriately, that's probably the best option. |
I just reviewed the error handling — mostly I like it. Would it be sensible to use common high-part for the two error constants? It would be nice to have some Looking at Rand's
|
Hm, I think we better to do it in the
I think conversion into |
We already do repeat-on-error for RDRAND.
Excepting that we have a couple of custom error codes. |
We follow Intel recommendations here (see section 5.2.1), IIRC in tight loop approximately each 2nd-4th execution of |
I think retry-on-interrupt is applicable to all users as with RDRAND? The difference is importance; it may be that interrupt errors are rare enough that no one would notice?
I still plan to discuss using RDRAND as a backup option. That's another discussion, but if we did do so would have some impact here. |
Using Alternatively we could just use |
The WASM implementations in #10 left a few errors poorly handled (marked TODO): two cases with a static string description and two cases with a Being able to forward an error would be nice but is not essential. Safely forwarding another error requires either a tagged enum over all possible sources or an allocator, as I understand it; neither are ideal. So what is the best option? Can a single type be sufficient for both And can we design a better solution for Perhaps the best option is to keep the current type but map each error classification to a specific constant. |
I prefer this option. I think we can document error codes in the |
How do you think we should deal with forwarded errors then?
The only useful methods this type gives us come from the Should we use |
Yes, I think it will be the best option. |
There is an option we could use here if we wanted: something akin to the UNIX fn set_err(msg: &'static str);
fn get_last_err() -> &str;
// or, for cfg(std):
fn set_err<T: ToString>(msg: T); This would be fully
|
I don't think that such extra-complexity is warranted (plus it will be even less idiomatic that As was written in the rust-random/rand#715 I think in addition to |
I think we can close this issue? |
If we are to make this crate independent of
rand_core
, then we need to include an error type here.We could simply copy the one
rand_core
uses; I think something simpler and equivalent onno_std
may be preferable however. A quick look at the code shows that where we do include a cause, we are mostly just using an integer error code. Whether it is even worth forwarding the cause is another question.The text was updated successfully, but these errors were encountered: