[PATCH] guix: ui: Improved error reporting when user file eval fails

  • Open
  • quality assurance status badge
Details
2 participants
  • Xinglu Chen
  • Rovanion Luckey
Owner
unassigned
Submitted by
Rovanion Luckey
Severity
normal
R
R
Rovanion Luckey wrote on 26 Feb 2021 23:36
(address . guix-patches@gnu.org)
CAAaf0CAFkDTO=yTtkEQ5DxV0Vs0i7mmCFHn_0J4ucnys+AnqzQ@mail.gmail.com
Added a specific error message for when the user provided scheme file being
evaluated in turn fails to load another file. Also clearified the error
message given on generic system errors, to make it clear where the error
originates from.

See attached patch.
Attachment: file
From 57126cbff38de728d64797551239723ed18575a5 Mon Sep 17 00:00:00 2001
From: Rovanion Luckey <rovanion.luckey@gmail.com>
Date: Fri, 26 Feb 2021 23:23:14 +0100
Subject: [PATCH] guix: ui: Improved error reporting when user file eval fails
due to system errors

Added a specific error message for when the user provided scheme file being evaluated in turn fails to load another file. Also clearified the error message given on generic system errors, to make it clear where the error originates from.
---
guix/ui.scm | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

Toggle diff (22 lines)
diff --git a/guix/ui.scm b/guix/ui.scm
index 7fbd4c63a2..0eabf136f6 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -373,9 +373,14 @@ it doesn't."
"Report the failure to load FILE, a user-provided Scheme file.
ARGS is the list of arguments received by the 'throw' handler."
(match args
+ (('system-error "open-file" . rest)
+ (let ((err (system-error-errno args))
+ (file-which-failed-to-open (car (cdr (car (cdr rest))))))
+ (report-error (G_ "while evaluating '~a', it failed opening '~a' with the error: ~a~%")
+ file file-which-failed-to-open (strerror err))))
(('system-error . rest)
(let ((err (system-error-errno args)))
- (report-error (G_ "failed to load '~a': ~a~%") file (strerror err))))
+ (report-error (G_ "failed to evaluate '~a', it raised the error: ~a~%") file (strerror err))))
(('read-error "scm_i_lreadparen" message _ ...)
;; Guile's missing-paren messages are obscure so we make them more
;; intelligible here.
--
2.30.0
X
X
Xinglu Chen wrote on 23 Mar 2021 14:18
87o8fadn50.fsf@yoctocell.xyz
On Fri, Feb 26 2021, Rovanion Luckey wrote:

Toggle quote (5 lines)
> Added a specific error message for when the user provided scheme file being
> evaluated in turn fails to load another file. Also clearified the error
> message given on generic system errors, to make it clear where the error
> originates from.

Great, much better than just saying "error: VAR unbound variable".

Toggle quote (3 lines)
> Added a specific error message for when the user provided scheme file
> being evaluated in turn fails to load another file. Also clearified

Typo fix, s/clearified/clarified
R
R
Rovanion Luckey wrote on 24 Mar 2021 14:36
(address . 46805@debbugs.gnu.org)(name . Xinglu Chen)(address . public@yoctocell.xyz)
CAAaf0CANSABsZO2DsZmBiuuq52MBmWCk-xtLoTnGN8jauZe_ow@mail.gmail.com
Fixed the typo in the attached patch.
Attachment: file
From 57126cbff38de728d64797551239723ed18575a5 Mon Sep 17 00:00:00 2001
From: Rovanion Luckey <rovanion.luckey@gmail.com>
Date: Fri, 26 Feb 2021 23:23:14 +0100
Subject: [PATCH] guix: ui: Improved error reporting when user file eval fails
due to system errors

Added a specific error message for when the user provided scheme file being evaluated in turn fails to load another file. Also clarified the error message given on generic system errors, to make it clear where the error originates from.
---
guix/ui.scm | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

Toggle diff (22 lines)
diff --git a/guix/ui.scm b/guix/ui.scm
index 7fbd4c63a2..0eabf136f6 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -373,9 +373,14 @@ it doesn't."
"Report the failure to load FILE, a user-provided Scheme file.
ARGS is the list of arguments received by the 'throw' handler."
(match args
+ (('system-error "open-file" . rest)
+ (let ((err (system-error-errno args))
+ (file-which-failed-to-open (car (cdr (car (cdr rest))))))
+ (report-error (G_ "while evaluating '~a', it failed opening '~a' with the error: ~a~%")
+ file file-which-failed-to-open (strerror err))))
(('system-error . rest)
(let ((err (system-error-errno args)))
- (report-error (G_ "failed to load '~a': ~a~%") file (strerror err))))
+ (report-error (G_ "failed to evaluate '~a', it raised the error: ~a~%") file (strerror err))))
(('read-error "scm_i_lreadparen" message _ ...)
;; Guile's missing-paren messages are obscure so we make them more
;; intelligible here.
--
2.30.0
R
R
Rovanion Luckey wrote on 12 Oct 2021 20:14
[PATCH] guix: ui: Improved error reporting when user file eval fails
(address . 46805@debbugs.gnu.org)
CAAaf0CAjEhNoSMRAcPemb2utXEFVXq0tPwkVw=JYP8WcRBegnA@mail.gmail.com
I should pattern match instead of using that long (car (cdr (car))) line
like something along the lines of (let ((which-file-failed (match rest ((_
_ file) file)))) ...). This will need the module (ice-9 match).
Attachment: file
R
R
Rovanion Luckey wrote on 12 Oct 2021 20:16
(address . 46805@debbugs.gnu.org)
CAAaf0CByTUjgFeWM7B+02zREqtn-QBwyj0KfRtpdiKNHEnZnmg@mail.gmail.com
Or maybe even better, I could do that on the args match: ('system-error
"open-file" . rest) becomes ('system-error "open-file" _ which-file-failed
. rest).

Both these suggestions should be credited to roptat.
Attachment: file
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 46805@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 46805
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch