[pan] Improve the log messages on connection errors



commit b41791fd9fe2228ed7c4e1ba80a1f880eb500436
Author: Thomas Tanner <thosrtanner googlemail com>
Date:   Thu Aug 11 09:25:30 2022 +0100

    Improve the log messages on connection errors

 pan/tasks/socket-impl-gio.cc     | 12 ++++++------
 pan/tasks/socket-impl-openssl.cc | 12 ++++++------
 2 files changed, 12 insertions(+), 12 deletions(-)
---
diff --git a/pan/tasks/socket-impl-gio.cc b/pan/tasks/socket-impl-gio.cc
index b9c44cd..9b14232 100644
--- a/pan/tasks/socket-impl-gio.cc
+++ b/pan/tasks/socket-impl-gio.cc
@@ -55,10 +55,10 @@ extern "C" {
     return buf;
   }
   */
-  static const char*
-  get_last_error (int err)
+  static std::string
+  get_last_error (int err, char const *hpbuf)
   {
-    const char * msg = 0;
+    std::string msg;
     switch(err) {
       case WSANOTINITIALISED: msg = "No successful WSAStartup call yet."; break;
       case WSAENETDOWN: msg = "The network subsystem has failed."; break;
@@ -72,7 +72,7 @@ extern "C" {
       case 11001: msg = "Host not found"; break;
       default: msg = "Connect failed";
     }
-    return msg;
+    return msg + " (" + hpbuf + ")";
   }
 
 #else
@@ -127,7 +127,7 @@ namespace
 
       err = WSAGetLastError();
       if (err || !ans) {
-        setme_err = get_last_error (err);
+        setme_err = get_last_error (err, hpbuf);
         return 0;
       }
 
@@ -153,7 +153,7 @@ namespace
 
       if (err) {
         closesocket (sockfd);
-        setme_err = get_last_error (err);
+        setme_err = get_last_error (err, hpbuf);
         return 0;
       }
     }
diff --git a/pan/tasks/socket-impl-openssl.cc b/pan/tasks/socket-impl-openssl.cc
index 7b12556..b704383 100644
--- a/pan/tasks/socket-impl-openssl.cc
+++ b/pan/tasks/socket-impl-openssl.cc
@@ -65,10 +65,10 @@ extern "C" {
 //  }
 
 
-  const char*
-  get_last_error (int err)
+  static std::string
+  get_last_error (int err, char const *hpbuf)
   {
-    const char * msg = 0;
+    std::string msg;
     switch(err) {
       case WSANOTINITIALISED: msg = "No successful WSAStartup call yet."; break;
       case WSAENETDOWN: msg = "The network subsystem has failed."; break;
@@ -82,7 +82,7 @@ extern "C" {
       case 11001: msg = "Host not found"; break;
       default: msg = "Connect failed";
     }
-    return msg;
+    return msg + " (" + hpbuf + ")";
   }
 
 #else
@@ -167,7 +167,7 @@ GIOChannelSocketGnuTLS :: create_channel (const StringView& host_in, int port, s
 
     err = WSAGetLastError();
     if (err || !ans) {
-      setme_err = get_last_error (err);
+      setme_err = get_last_error (err, hpbuf);
       return 0;
     }
 
@@ -194,7 +194,7 @@ GIOChannelSocketGnuTLS :: create_channel (const StringView& host_in, int port, s
 
     if (err) {
       closesocket (sockfd);
-      setme_err = get_last_error (err);
+      setme_err = get_last_error (err, hpbuf);
       return 0;
     }
   }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]