local-ip-address
local-ip-address copied to clipboard
Use Os Error
hi,
Checked the reported error on getifaddrs
failed,
https://github.com/EstebanBorai/local-ip-address/blob/main/src/macos.rs#L38
I think it's more reasonable to return the specific os error from std::io::Error::last_os_error()
Hi @bigdogs!
I see last_os_error
may provide more details on the error in question.
For the current implementation, and to have backwards compatibility, I think we could use that to fill Error::StrategyError
with the corresponding error message, what do you think?
Hi, @EstebanBorai
thiserror can wrap an error type, I think we can add a new enum item for std io error
#[error("some description here...")]
IOError(#[from] std::io::Error),
Coverting last_os_error
to message is OK if user doesn't care about the error detail.
Hi, @EstebanBorai
thiserror can wrap an error type, I think we can add a new enum item for std io error
#[error("some description here...")] IOError(#[from] std::io::Error),
Coverting
last_os_error
to message is OK if user doesn't care about the error detail.
Sounds good. We could add a new item but Im afraid users would have to check on more enums making error handling a bit harder.
Perhaps we could draft a new release where the StrategyError
variant provides a native OS error with all the details (the one you refer to here).
Its important that we keep in mind that the same abstraction on the error must be provided to every supported platform (macOS, Linux and Windows).
To do so, I suggest we have a trait
which is implemented to each of these OS errors and retrieves details using functions, similar to
how diesel handles database errors for different engines.
How do you see this?
Sounds good to me 👍
Sounds good to me 👍
If you are interested on working on this, please don't hesitate on opening a PR I'm happy to help whenever I can!