Too often the message 'connect: no such file or directory' appears deep
in network code, and it is very hard to figure out where it is coming
from.  At least seeing the path (for example, in the case of a UNIX
socket) will help the user to debug their code.

 * libguile/socket.c: extra error handling in scm_bind and scm_connect
                      functions.
---
 libguile/socket.c | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/libguile/socket.c b/libguile/socket.c
index 101afd80d..9deecb48c 100644
--- a/libguile/socket.c
+++ b/libguile/socket.c
@@ -932,7 +932,19 @@ SCM_DEFINE (scm_connect, "connect", 2, 1, 1,
       errno = save_errno;
       if (errno == EINPROGRESS || errno == EAGAIN)
         return SCM_BOOL_F;
-      SCM_SYSERROR;
+      if (scm_is_string (address))
+        {
+          SCM_SYSERROR_MSG
+            ("'~A': ~A",
+             scm_cons (address,
+                       scm_cons (scm_strerror (scm_from_int (errno)),
+                                 SCM_EOL)),
+             errno);
+        }
+      else
+        {
+          SCM_SYSERROR;
+        }
     }
   free (soka);
   return SCM_BOOL_T;
@@ -1002,7 +1014,19 @@ SCM_DEFINE (scm_bind, "bind", 2, 1, 1,
 
     free (soka);
     errno = save_errno;
-    SCM_SYSERROR;
+    if (scm_is_string (address))
+      {
+        SCM_SYSERROR_MSG
+          ("'~A': ~A",
+           scm_cons (address,
+                     scm_cons (scm_strerror (scm_from_int (errno)),
+                               SCM_EOL)),
+           errno);
+      }
+    else
+      {
+        SCM_SYSERROR;
+      }
   }
   free (soka);
   return SCM_UNSPECIFIED;
-- 
2.46.0

Reply via email to