bug-guix
[Top][All Lists]
Advanced

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

bug#48561: "Daemon not running" exception when avahi-daemon is not runni


From: Maxime Devos
Subject: bug#48561: "Daemon not running" exception when avahi-daemon is not running
Date: Fri, 21 May 2021 16:37:48 +0200
User-agent: Evolution 3.34.2

Hi Mathieu,

Mathieu Othacehe schreef op vr 21-05-2021 om 15:23 [+0200]:
> +        (catch 'avahi-error
> +          (lambda ()
> +            (avahi-browse-service-thread service-proc
> +                                         #:types %services))
> +          (lambda (key err function . _)
> +            (cond
> +             ((eq? err error/no-daemon)
> +              (warning (G_ "Avahi daemon is not running, \
> +cannot auto-discover substitutes servers.~%"))))
> +            (exit 1)))))))

Shouldn't this code print an an error message when err is something
other than error/no-daemon?  You can use error->string. Two examples
from (guile-avahi)Error handling:

2.4 Error Handling
==================

Avahi errors are implemented as Scheme exceptions (*note exceptions in
Guile: (guile)Exceptions.).  Each time a Avahi function returns an
error, an exception with key 'avahi-error' is raised.  The additional
arguments that are thrown include an error code and the name of the
Avahi procedure that raised the exception.  The error code is pretty
much like an enumerate value: it is one of the 'error/' variables
exported by the '(avahi)' module (*note Enumerates and Constants::).
Exceptions can be turned into error messages using the 'error->string'
procedure.

   The following examples illustrates how Avahi exceptions can be
handled:

     (let ((poll (make-simple-poll)))

       ;;
       ;; ...
       ;;

       (catch 'avahi-error
         (lambda ()
           (run-simple-poll (simple-poll poll)))
         (lambda (key err function . currently-unused)
           (format (current-error-port)
                   "an Avahi error was raised by `~a': ~a~%"
                   function (error->string err)))))

   Again, error values can be compared using 'eq?':

         ;; `avahi-error' handler.
         (lambda (key err function . currently-unused)
           (if (eq? err error/no-daemon)
               (format (current-error-port)
                       "~a: the Avahi daemon is not running~%"
                       function)))

Otherwise LGTM, but I haven't tested.

Greetings,
Maxime.

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]