unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Julien Lepiller <julien@lepiller.eu>
Cc: 49671@debbugs.gnu.org
Subject: [bug#49671] [PATCH] guix: records: Improve error reporting.
Date: Wed, 04 Aug 2021 17:19:47 +0200	[thread overview]
Message-ID: <87bl6dp78s.fsf@gnu.org> (raw)
In-Reply-To: <20210721014047.3878a0c7@tachikoma.lepiller.eu> (Julien Lepiller's message of "Wed, 21 Jul 2021 01:40:47 +0200")

Hello!

Julien Lepiller <julien@lepiller.eu> skribis:

> Here are the cases that are handled and the associated message:
>
> (operating-system
>   services)
> guix system: error: services: invalid field specifier. The format of a
> field is `(services value)'
>
> (operating-system
>   (services))
> test.scm:2:2: error: (services): Value missing in field specifier. The
> format of a field is `(services value)'.
>
> (operating-system
>   (services 1 2 3))
> test.scm:2:2: error: (services 1 2 3): multiple values in field
> specifier. Got 3 values associated with key services. Values are:
> 1
> 2
> 3
>
> (operating-system
>   ())
> guix system: error: (): invalid field specifier. The format of a field
> is `(field value)'
>
> (operating-system
>   ((services %desktop-services)))
> test.scm:2:2: error: ((services %desktop-services)): invalid field
> specifier. (services %desktop-services) is not a valid field name.
>
>
> Of course, we can improve these error messages, and internationalize
> them.

I like the idea!

I would prefer for error messages to be plain errors, without hints, so:

  test.scm:2:2: error: (services 1 2 3): multiple values in field specifier

(Not a sentence, no period.)

But I’d also like to have hints, and ideally all hints should be
reported consistently, via ‘&fix-hint’ or similar.

Thankfully, we can do that via (guix diagnostics) + SRFI-35/34:

  (raise (condition
           (&syntax (form 'x) (subform 'y))
           (&fix-hint (hint "Consider fixing this."))))

‘call-with-error-handling’ in (guix ui) might need to be adjusted.

The only downside is that (guix records) would now depend on another
Guix modules, which I tried to avoid so far so it could be more easily
reused elsewhere.  But that’s the price to pay to get consistent error
reports, and I think it’s okay.

Note that ‘tests/guix-system.sh’ and a couple of other files test exact
error reports, so we’ll have to make sure it still works and possibly
augment the tests.

WDYT?

Thanks,
Ludo’.




  parent reply	other threads:[~2021-08-04 17:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-20 23:40 [bug#49671] [PATCH] guix: records: Improve error reporting Julien Lepiller
2021-07-21 19:21 ` Sarah Morgensen
2021-08-04 15:19 ` Ludovic Courtès [this message]
2021-10-31  2:06 ` Julien Lepiller
2021-11-22  2:40   ` [bug#49671] [PATCH v3] " Julien Lepiller
2022-07-17  6:23     ` Julien Lepiller

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=87bl6dp78s.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=49671@debbugs.gnu.org \
    --cc=julien@lepiller.eu \
    /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).