diff options
author | Ludovic Courtès <ludo@gnu.org> | 2015-04-07 22:07:25 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2015-04-07 22:28:36 +0200 |
commit | 1151f6aeae281ae391f925f5cee086f1c2a0728a (patch) | |
tree | 5784a8ffa2b6ab2960620bb70732ea55b4a0e3e5 /guix/ui.scm | |
parent | c8bfa5b425c1285cbd4c4a3283f09e2ebb6687f9 (diff) | |
download | gnu-guix-1151f6aeae281ae391f925f5cee086f1c2a0728a.tar gnu-guix-1151f6aeae281ae391f925f5cee086f1c2a0728a.tar.gz |
ui: Add 'report-load-error'.
* guix/scripts/system.scm (read-operating-system): Replace error
handling code by a call to 'report-load-error'.
* guix/ui.scm (report-load-error): New procedure.
Diffstat (limited to 'guix/ui.scm')
-rw-r--r-- | guix/ui.scm | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/guix/ui.scm b/guix/ui.scm index 4929f93590..80a4a6338a 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -47,6 +47,7 @@ P_ report-error leave + report-load-error show-version-and-exit show-bug-report-information string->number* @@ -130,6 +131,23 @@ messages." (report-error args ...) (exit 1))) +(define (report-load-error file args) + "Report the failure to load FILE, a user-provided Scheme file, and exit. +ARGS is the list of arguments received by the 'throw' handler." + (match args + (('system-error . _) + (let ((err (system-error-errno args))) + (leave (_ "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: error: ~a~%") + (location->string loc) message) + (exit 1))) + ((error args ...) + (report-error (_ "failed to load '~a':~%") file) + (apply display-error #f (current-error-port) args) + (exit 1)))) + (define (install-locale) "Install the current locale settings." (catch 'system-error |