diff mbox series

[bug#46805] guix: ui: Improved error reporting when user file eval fails

Message ID CAAaf0CAFkDTO=yTtkEQ5DxV0Vs0i7mmCFHn_0J4ucnys+AnqzQ@mail.gmail.com
State New
Headers show
Series [bug#46805] guix: ui: Improved error reporting when user file eval fails | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

Rovanion Luckey Feb. 26, 2021, 10:36 p.m. UTC
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.

Comments

Xinglu Chen March 23, 2021, 1:18 p.m. UTC | #1
On Fri, Feb 26 2021, Rovanion Luckey wrote:

> 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".

> 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
Rovanion Luckey Oct. 12, 2021, 6:14 p.m. UTC | #2
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).
Rovanion Luckey Oct. 12, 2021, 6:16 p.m. UTC | #3
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.
diff mbox series

Patch

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(-)

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