Commit Graph

12 Commits

Author SHA1 Message Date
Ludovic Courtès 9f3ea03516
diagnostics: Factorize 'absolute-location'.
* guix/scripts/style.scm (absolute-location): Move to...
* guix/diagnostics.scm (absolute-location): ... here.
* guix/upstream.scm (update-package-source): Use it.
2023-05-31 23:25:25 +02:00
Maxim Cournoyer 53cd5923ef
diagnostics: Fix typo about 0-indexed COL in location.
* guix/diagnostics.scm (source-properties->location): The location column is
0-indexed, not 1-indexed (the same as in source-properties, so the code is
accurate).
2022-05-31 14:52:14 -04:00
Ludovic Courtès 13307c198b
diagnostics: Turn diagnostic locations into hyperlinks.
* guix/diagnostics.scm (print-diagnostic-prefix): Use
'location->hyperlink' when 'supports-hyperlinks?' returns true.
2022-04-08 23:59:48 +02:00
Ludovic Courtès 3da62bf5aa
ui: Move 'location->hyperlink' to (guix diagnostics).
* guix/ui.scm (location->hyperlink): Move to...
* guix/diagnostics.scm: ... here.
* guix/scripts/system/search.scm: Adjust imports accordingly.
2022-04-08 23:59:48 +02:00
Josselin Poiret 346d2f6488
diagnostics: Add syntax to capture arguments' syntax-properties.
* guix/diagnostics.scm (define-with-syntax-properties): Add it.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2021-11-17 23:05:58 +01:00
Ludovic Courtès 524c9800af
diagnostics, ui: Adjust to 'read-error' and 'syntax-error' in Guile 3.0.6.
* guix/diagnostics.scm (source-properties->location): Add clause for
vectors.
* guix/ui.scm (report-load-error): Tweak 'read-error' handling for 3.0.6.
* tests/guix-package.sh: Relax regexp for the "unbound variable"
diagnostic check.
* tests/guix-system.sh: Adjust "missing closing paren" check for 3.0.6.
* tests/records.scm (location-alist): New procedure.
("define-record-type* & wrong field specifier")
("define-record-type* & wrong field specifier, identifier")
("define-record-type* & duplicate initializers"): Use it.
2021-04-29 01:22:04 +02:00
Ludovic Courtès 252a1926bc
diagnostics: Add '&formatted-message'.
This allows 'gettext' to be called on the format string at the site
where the exception is caught (rather than the site where it's thrown).
It also allows for argument highlighting.

* guix/diagnostics.scm (&formatted-message): New condition type.
(check-format-string): New procedure.
(formatted-message): New macro.
* guix/ui.scm (report-load-error): Add clause for 'formatted-message?'.
(warn-about-load-error): Likewise.
(call-with-error-handling): Likewise.
(read/eval): Likewise.
2020-07-25 19:11:36 +02:00
Ludovic Courtès 860f3d7749
diagnostics: Add a procedural variant of diagnostic procedures.
Callers can pass 'report-error', 'warning', etc. to 'apply'.

* guix/diagnostics.scm (trivial-format-string?): New procedure, moved
from...
(highlight-argument): ... here.
(define-diagnostic): Add 'identifier?' clause.
(emit-diagnostic): New procedure.
2020-07-25 19:11:36 +02:00
Ludovic Courtès f9a8dd053c
utils: Move '&fix-hint' to (guix diagnostics).
* guix/utils.scm (&fix-hint): Move to...
* guix/diagnostics.scm (&fix-hint): ... here.
* gnu.scm: Adjust imports accordingly.
* gnu/system/mapped-devices.scm: Likewise.
* guix/channels.scm: Likewise.
* guix/profiles.scm: Likewise.
* guix/scripts/system/reconfigure.scm: Likewise.
* guix/ssh.scm: Likewise.
2020-07-25 19:11:36 +02:00
Ludovic Courtès a5e2fc7376
utils: Move <location> and '&error-location' to (guix diagnostics).
* guix/utils.scm (<location>, source-properties->location)
(location->source-properties, &error-location): Move to...
* guix/diagnostics.scm: ... here.
* gnu.scm: Adjust imports accordingly.
* gnu/machine.scm: Likewise.
* gnu/system.scm: Likewise.
* gnu/tests.scm: Likewise.
* guix/inferior.scm: Likewise.
* tests/channels.scm: Likewise.
* tests/packages.scm: Likewise.
2020-07-25 19:11:36 +02:00
Ludovic Courtès d229215051
diagnostics: Avoid highlighting complete messages.
* guix/diagnostics.scm (%highlight-argument): Don't highlight ARG if it
contains white space.
2019-08-28 18:52:52 +02:00
Ludovic Courtès 1b5ee3bdaa
Add (guix diagnostics).
* guix/ui.scm (warning, info, report-error, leave)
(location->string, guix-warning-port, program-name)
(highlight-argument, %highlight-argument, define-diagnostic)
(%warning-color, %info-color, %error-color)
(print-diagnostic-prefix): Move to...
* guix/diagnostics.scm: ... here.  New file.
* Makefile.am (MODULES): Add it.
2019-06-03 23:18:47 +02:00