aboutsummaryrefslogtreecommitdiff
path: root/guix
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2015-04-07 22:27:45 +0200
committerLudovic Courtès <ludo@gnu.org>2015-04-07 22:28:36 +0200
commit4ae7559fd62c03a800b010c228639f18b9f58006 (patch)
tree70b5a9f9f214993fdad29018ed10835a951090d0 /guix
parent1151f6aeae281ae391f925f5cee086f1c2a0728a (diff)
downloadgnu-guix-4ae7559fd62c03a800b010c228639f18b9f58006.tar
gnu-guix-4ae7559fd62c03a800b010c228639f18b9f58006.tar.gz
gnu: Emit a warning when a package module cannot be loaded.
* guix/ui.scm (warn-about-load-error): New procedure. * gnu/packages.scm (package-modules): Wrap 'resolve-interface' call in 'catch #t', and call 'warn-about-load-error' in handler.
Diffstat (limited to 'guix')
-rw-r--r--guix/ui.scm16
1 files changed, 16 insertions, 0 deletions
diff --git a/guix/ui.scm b/guix/ui.scm
index 80a4a6338a..9e75a35d16 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -48,6 +48,7 @@
report-error
leave
report-load-error
+ warn-about-load-error
show-version-and-exit
show-bug-report-information
string->number*
@@ -148,6 +149,21 @@ ARGS is the list of arguments received by the 'throw' handler."
(apply display-error #f (current-error-port) args)
(exit 1))))
+(define (warn-about-load-error file args) ;FIXME: factorize with ↑
+ "Report the failure to load FILE, a user-provided Scheme file, without
+exiting. ARGS is the list of arguments received by the 'throw' handler."
+ (match args
+ (('system-error . _)
+ (let ((err (system-error-errno args)))
+ (warning (_ "failed to load '~a': ~a~%") file (strerror err))))
+ (('syntax-error proc message properties form . rest)
+ (let ((loc (source-properties->location properties)))
+ (format (current-error-port) (_ "~a: warning: ~a~%")
+ (location->string loc) message)))
+ ((error args ...)
+ (warning (_ "failed to load '~a':~%") file)
+ (apply display-error #f (current-error-port) args))))
+
(define (install-locale)
"Install the current locale settings."
(catch 'system-error