From 6e8f871198b661b631a319f3abaef71bc6269fb7 Mon Sep 17 00:00:00 2001 From: Cyprien Nicolas Date: Thu, 10 Apr 2014 10:07:06 +0200 Subject: [PATCH] Improve socket connection errors handling. If the user running `deco' does not have the rights privileges to open the unix socket, the raised exception produces a backtrace. * modules/dmd/comm.scm (open-connection): Add a (catch 'system-error...) guard around the connect function call. The handler will abort the program in case of error. --- modules/dmd/comm.scm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/dmd/comm.scm b/modules/dmd/comm.scm index d3743e6..4a0d383 100644 --- a/modules/dmd/comm.scm +++ b/modules/dmd/comm.scm @@ -63,7 +63,14 @@ return the socket." (with-fluids ((%default-port-encoding "UTF-8")) (let ((sock (socket PF_UNIX SOCK_STREAM 0)) (address (make-socket-address PF_UNIX file))) - (connect sock address) + (catch 'system-error + (lambda () + (connect sock address)) + (lambda (key . args) + (display (format #f "Error: Cannot connect to socket `~a': ~a\n" + file (apply format #f (cadr args) (caddr args))) + (current-error-port)) + (quit 1))) sock))) (define (read-command port) -- 1.8.5.4