Shared uv_strerror
This commit is contained in:
parent
fd2b04d784
commit
808bb8ed0b
@ -120,24 +120,3 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
|
||||
assert(0 && "unreachable");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* TODO Pull in error messages so we don't have to
|
||||
* a) rely on what the system provides us
|
||||
* b) reverse-map the error codes
|
||||
*/
|
||||
#define UV_STRERROR_GEN(val, name, s) case UV_##name : return s;
|
||||
const char* uv_strerror(uv_err_t err) {
|
||||
int errorno;
|
||||
|
||||
if (err.code == UV_EADDRINFO) {
|
||||
return gai_strerror(errorno);
|
||||
}
|
||||
|
||||
switch (err.code) {
|
||||
UV_ERRNO_MAP(UV_STRERROR_GEN)
|
||||
default:
|
||||
return strerror(err.sys_errno_);
|
||||
}
|
||||
}
|
||||
#undef UV_STRERROR_GEN
|
||||
|
||||
@ -62,6 +62,17 @@ const char* uv_err_name(uv_err_t err) {
|
||||
#undef UV_ERR_NAME_GEN
|
||||
|
||||
|
||||
#define UV_STRERROR_GEN(val, name, s) case UV_##name : return s;
|
||||
const char* uv_strerror(uv_err_t err) {
|
||||
switch (err.code) {
|
||||
UV_ERRNO_MAP(UV_STRERROR_GEN)
|
||||
default:
|
||||
return "Unknown system error";
|
||||
}
|
||||
}
|
||||
#undef UV_STRERROR_GEN
|
||||
|
||||
|
||||
void uv__set_error(uv_loop_t* loop, uv_err_code code, int sys_error) {
|
||||
loop->last_err.code = code;
|
||||
loop->last_err.sys_errno_ = sys_error;
|
||||
|
||||
@ -64,20 +64,6 @@ void uv_fatal_error(const int errorno, const char* syscall) {
|
||||
}
|
||||
|
||||
|
||||
/* TODO: thread safety */
|
||||
static char* last_err_str_ = NULL;
|
||||
|
||||
#define UV_STRERROR_GEN(val, name, s) case UV_##name : return s;
|
||||
const char* uv_strerror(uv_err_t err) {
|
||||
switch (err.code) {
|
||||
UV_ERRNO_MAP(UV_STRERROR_GEN)
|
||||
default:
|
||||
return "Unknown system error";
|
||||
}
|
||||
}
|
||||
#undef UV_STRERROR_GEN
|
||||
|
||||
|
||||
uv_err_code uv_translate_sys_error(int sys_errno) {
|
||||
switch (sys_errno) {
|
||||
case ERROR_SUCCESS: return UV_OK;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user