unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: Maxime Devos <maximedevos@telenet.be>
To: Mathieu Othacehe <othacehe@gnu.org>
Cc: 48561@debbugs.gnu.org
Subject: bug#48561: "Daemon not running" exception when avahi-daemon is not running
Date: Fri, 21 May 2021 16:37:48 +0200	[thread overview]
Message-ID: <a0c712f64a1008c7d62a41a00e1081016066fc85.camel@telenet.be> (raw)
In-Reply-To: <87im3cqkzn.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 2177 bytes --]

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 #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

  reply	other threads:[~2021-05-21 14:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-21  8:48 bug#48561: "Daemon not running" exception when avahi-daemon is not running Maxime Devos
2021-05-21 13:23 ` Mathieu Othacehe
2021-05-21 14:37   ` Maxime Devos [this message]
2021-05-22 12:06     ` Mathieu Othacehe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a0c712f64a1008c7d62a41a00e1081016066fc85.camel@telenet.be \
    --to=maximedevos@telenet.be \
    --cc=48561@debbugs.gnu.org \
    --cc=othacehe@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).