adb: improve network_connect error messages.
Test: manual
Change-Id: If8747ba1951d3c87561fbd3fb4968821243b2ee2
diff --git a/adb/sysdeps/posix/network.cpp b/adb/sysdeps/posix/network.cpp
index 33ddb4e..4de240e 100644
--- a/adb/sysdeps/posix/network.cpp
+++ b/adb/sysdeps/posix/network.cpp
@@ -24,6 +24,7 @@
#include <string>
#include <android-base/logging.h>
+#include <android-base/stringprintf.h>
#include <cutils/sockets.h>
#include "adb_unique_fd.h"
@@ -136,11 +137,13 @@
return fd;
}
if (getaddrinfo_error != 0) {
- *error = gai_strerror(getaddrinfo_error);
- LOG(WARNING) << "failed to resolve host '" << host << "': " << *error;
+ *error = android::base::StringPrintf("failed to resolve host: '%s': %s", host.c_str(),
+ gai_strerror(getaddrinfo_error));
+ LOG(WARNING) << *error;
} else {
- *error = strerror(errno);
- LOG(WARNING) << "failed to connect to '" << host << "': " << *error;
+ *error = android::base::StringPrintf("failed to connect to '%s:%d': %s", host.c_str(), port,
+ strerror(errno));
+ LOG(WARNING) << *error;
}
return -1;
}