From: Eli Lindsey Date: Mon, 10 Jul 2017 15:54:21 +0000 (-0700) Subject: add the getnameinfo error code and v6 scope id to exception text X-Git-Tag: v2017.07.17.00~30 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d94e4de504098de980354c9a81209bb086db1e45;p=folly.git add the getnameinfo error code and v6 scope id to exception text Summary: Making the exception text more useful by adding getnameinfo's error code and the v6 scope id Reviewed By: yangchi Differential Revision: D5389137 fbshipit-source-id: e6b9b4edd7dd1859e0ed4d784b2f89a60a701955 --- diff --git a/folly/IPAddressV6.cpp b/folly/IPAddressV6.cpp index 038a68f9..1cb2ce6e 100644 --- a/folly/IPAddressV6.cpp +++ b/folly/IPAddressV6.cpp @@ -405,10 +405,15 @@ IPAddressV6 IPAddressV6::mask(size_t numBits) const { string IPAddressV6::str() const { char buffer[INET6_ADDRSTRLEN] = {0}; sockaddr_in6 sock = toSockAddr(); - if (!getnameinfo( - (sockaddr*)&sock, sizeof(sock), - buffer, INET6_ADDRSTRLEN, - nullptr, 0, NI_NUMERICHOST)) { + int error = getnameinfo( + (sockaddr*)&sock, + sizeof(sock), + buffer, + INET6_ADDRSTRLEN, + nullptr, + 0, + NI_NUMERICHOST); + if (!error) { string ip(buffer); return ip; } else { @@ -416,7 +421,11 @@ string IPAddressV6::str() const { "Invalid address with hex ", "'", detail::Bytes::toHex(bytes(), 16), - "'")); + "%", + sock.sin6_scope_id, + "'", + " , with error ", + gai_strerror(error))); } }