Consistency in namespace-closing comments
[folly.git] / folly / IPAddressV6.cpp
index 3490669dcbdd72db0cf2484c24e3e6708c045970..e40a08e5d17e317f43fb6a6056569da41b1511a1 100644 (file)
@@ -432,17 +432,14 @@ string IPAddressV6::str() const {
   if (scopeId != 0) {
     auto len = strlen(buffer);
     buffer[len] = '%';
+
+    auto errsv = errno;
     if (!if_indextoname(scopeId, buffer + len + 1)) {
-      throw IPAddressFormatException(to<std::string>(
-          "Invalid scope for address with hex ",
-          "'",
-          detail::Bytes::toHex(bytes(), 16),
-          "%",
-          scopeId,
-          "'",
-          " with error ",
-          strerror(errno)));
+      // if we can't map the if because eg. it no longer exists,
+      // append the if index instead
+      snprintf(buffer + len + 1, IFNAMSIZ, "%u", scopeId);
     }
+    errno = errsv;
   }
 
   return string(buffer);
@@ -517,4 +514,4 @@ bool IPAddressV6::inBinarySubnet(const std::array<uint8_t, 2> addr,
   auto masked = mask(numBits);
   return (std::memcmp(addr.data(), masked.bytes(), 2) == 0);
 }
-} // folly
+} // namespace folly