-
Notifications
You must be signed in to change notification settings - Fork 187
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
Deprecate and remove impl From<NonZeroU32> for Error
.
#455
Comments
I like this idea, having something like: impl Error {
pub const fn from_os_error(i32) -> Self;
pub const fn raw_os_error(self) -> Option<i32>
pub const fn new_custom(u16) -> Self;
const fn new_internal(u16) -> Self;
} seems reasonable to me. We may want to use EDIT: Should we also remove the |
@newpavlov decided to do this in #507, but I don't see a replacement. Should we add the following? pub const fn custom_code(self) -> Option<u16>; |
@dhardy |
If a custom source is used and it is wished to handle these errors somehow later — but no, I don't have any specific use case in mind.
Nothing changes here since we already have |
I meant that we can change for example Addition of such method will be a backwards compatible change, so we can do it later in the case if someone requests such method. |
Changing Sure, this can be added later if needed. |
The
From<NonZeroU32> for Error
implementation doesn't do any checking of its inputs; for example, it doesn't verify that an "internal" error code isn't being used, nor does it verify that any internal error code is actually a valid/known one.I propose:
pub const fn Error::new_custom(value: u16) -> Error
pub const fn Error::new_os(u32) -> Error
with range checking, as done in Enforce OS errors are in the allowed range. #441, though Enforce OS errors are in the allowed range. #441 doesn't make itpub
.impl From<NonZeroU32> for Error
as#[deprecated]
now.This way, internal errors will eventually only be able to be constructed from within the crate.
The text was updated successfully, but these errors were encountered: