summaryrefslogtreecommitdiff
path: root/guix/ui.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2017-11-09 23:31:18 +0100
committerLudovic Courtès <ludo@gnu.org>2017-11-09 23:54:47 +0100
commitdc856223f5eab57d8a4881782ec0f50abd12afa3 (patch)
tree69eac3c1c442bcb076c4f12ae965b0ba6b8cf356 /guix/ui.scm
parenta2985bb101faac9f085176e0329488b91b81dfb5 (diff)
ui: Add an 'unbound-variable' exception printer.
* guix/ui.scm (print-unbound-variable-error): New variable. Use it as the 'unbound-variable' printer.
Diffstat (limited to 'guix/ui.scm')
-rw-r--r--guix/ui.scm12
1 files changed, 12 insertions, 0 deletions
diff --git a/guix/ui.scm b/guix/ui.scm
index 9f790b6451..05782a537e 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -149,6 +149,18 @@ messages."
(report-error args ...)
(exit 1)))
+(define (print-unbound-variable-error port key args default-printer)
+ ;; Print unbound variable errors more nicely, and in the right language.
+ (match args
+ ((proc message (variable) _ ...)
+ ;; We can always omit PROC because when it's useful (i.e., different from
+ ;; "module-lookup"), it gets displayed before.
+ (format port (G_ "~a: unbound variable") variable))
+ (_
+ (default-printer))))
+
+(set-exception-printer! 'unbound-variable print-unbound-variable-error)
+
(define (make-user-module modules)
"Return a new user module with the additional MODULES loaded."
;; Module in which the machine description file is loaded.