User friendly error messages from errno
Opened this issue · 3 comments
Is there a way to get user-friendly messages (static str or other) from errno
numbers? I can't see anything except to refer to the table in cloudabi.txt:209.
For comparison, see from_raw_os_error
which uses sys::os::error_string
, which uses strerror_r
internally. It looks like CloudABI error codes don't match up with POSIX error codes so will you provide an equivalent?
Cloudlibc provides a strerror
and strerror_r
: https://github.com/NuxiNL/cloudlibc/blob/master/src/include/string.h#L71-L73
Hi Diggory,
It's safe to pass error codes from the Rust bindings to from_raw_os_error()
. On CloudABI, that function is also implemented using strerror()
. Inside of CloudABI's C library we ensure that the error codes are defined to match up with the ones from cloudabi.txt
:
https://github.com/NuxiNL/cloudlibc/blob/master/src/libc/errno/errno.c
That said, maybe there is some elegant way to expose documentation strings in cloudabi.txt
through the Rust bindings as well...? @m-ou-se thoughts?
Thanks for the quick response. I have no problem using from_raw_os_error
in that case so I guess this is just a documentation issue.