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

Deprecate and remove impl From<NonZeroU32> for Error. #455

Open
briansmith opened this issue Jun 4, 2024 · 1 comment
Open

Deprecate and remove impl From<NonZeroU32> for Error. #455

briansmith opened this issue Jun 4, 2024 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@briansmith
Copy link
Contributor

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:

This way, internal errors will eventually only be able to be constructed from within the crate.

@briansmith briansmith mentioned this issue Jun 4, 2024
@josephlr josephlr added this to the Next Release milestone Jun 4, 2024
@josephlr
Copy link
Member

josephlr commented Jun 21, 2024

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 i32 consistently for OS errors as that's what libstd uses (and it's the return type of errno).

EDIT: Should we also remove the Error::code method?

@josephlr josephlr added the enhancement New feature or request label Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants