Commit d94e4de5 authored by Eli Lindsey's avatar Eli Lindsey Committed by Facebook Github Bot

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
parent e8527d2e
...@@ -405,10 +405,15 @@ IPAddressV6 IPAddressV6::mask(size_t numBits) const { ...@@ -405,10 +405,15 @@ IPAddressV6 IPAddressV6::mask(size_t numBits) const {
string IPAddressV6::str() const { string IPAddressV6::str() const {
char buffer[INET6_ADDRSTRLEN] = {0}; char buffer[INET6_ADDRSTRLEN] = {0};
sockaddr_in6 sock = toSockAddr(); sockaddr_in6 sock = toSockAddr();
if (!getnameinfo( int error = getnameinfo(
(sockaddr*)&sock, sizeof(sock), (sockaddr*)&sock,
buffer, INET6_ADDRSTRLEN, sizeof(sock),
nullptr, 0, NI_NUMERICHOST)) { buffer,
INET6_ADDRSTRLEN,
nullptr,
0,
NI_NUMERICHOST);
if (!error) {
string ip(buffer); string ip(buffer);
return ip; return ip;
} else { } else {
...@@ -416,7 +421,11 @@ string IPAddressV6::str() const { ...@@ -416,7 +421,11 @@ string IPAddressV6::str() const {
"Invalid address with hex ", "Invalid address with hex ",
"'", "'",
detail::Bytes::toHex(bytes(), 16), detail::Bytes::toHex(bytes(), 16),
"'")); "%",
sock.sin6_scope_id,
"'",
" , with error ",
gai_strerror(error)));
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment