diff options
Diffstat (limited to 'Userland/Libraries/LibC/netdb.cpp')
-rw-r--r-- | Userland/Libraries/LibC/netdb.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Userland/Libraries/LibC/netdb.cpp b/Userland/Libraries/LibC/netdb.cpp index 96b934a662..69e9e3e992 100644 --- a/Userland/Libraries/LibC/netdb.cpp +++ b/Userland/Libraries/LibC/netdb.cpp @@ -829,4 +829,26 @@ int getnameinfo(const struct sockaddr* __restrict addr, socklen_t addrlen, char* return 0; } + +void herror(char const* s) +{ + dbgln("herror(): {}: {}", s, hstrerror(h_errno)); + warnln("{}: {}", s, hstrerror(h_errno)); +} + +char const* hstrerror(int err) +{ + switch (err) { + case HOST_NOT_FOUND: + return "The specified host is unknown."; + case NO_DATA: + return "The requested name is valid but does not have an IP address."; + case NO_RECOVERY: + return "A nonrecoverable name server error occurred."; + case TRY_AGAIN: + return "A temporary error occurred on an authoritative name server. Try again later."; + default: + return "Unknown error."; + } +} } |