From 8b53a91aa50206cf872c37554b943e971f220430 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Tue, 2 Jun 2015 11:01:17 -0400 Subject: [PATCH] lib/socket: intro `HErrno::to_s` MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- lib/socket/socket_c.nit | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/socket/socket_c.nit b/lib/socket/socket_c.nit index 5962b3d..94eecd7 100644 --- a/lib/socket/socket_c.nit +++ b/lib/socket/socket_c.nit @@ -511,4 +511,21 @@ extern class HErrno `{ int `} # A temporary error occurred on an authoritative name server, try again later fun try_again: Bool `{ return self == TRY_AGAIN; `} + + redef fun to_s + do + if host_not_found then + return "The specified host is unknown" + else if no_address then + return "The requested name is valid but does not have an IP address" + else if no_recovery then + return "A nonrecoverable name server error occurred" + else if try_again then + return "A temporary error occurred on an authoritative name server, try again later" + else + # This may happen if another call was made to `gethostbyname` + # before we fetch the error code. + return "Unknown error on `gethostbyname`" + end + end end -- 1.7.9.5