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.
This commit is contained in:
parent
c8bfa5b425
commit
1151f6aeae
|
@ -69,21 +69,7 @@
|
||||||
(set-current-module %user-module)
|
(set-current-module %user-module)
|
||||||
(primitive-load file))))
|
(primitive-load file))))
|
||||||
(lambda args
|
(lambda args
|
||||||
(match args
|
(report-load-error file args))))
|
||||||
(('system-error . _)
|
|
||||||
(let ((err (system-error-errno args)))
|
|
||||||
(leave (_ "failed to open operating system file '~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 operating system file '~a':~%")
|
|
||||||
file)
|
|
||||||
(apply display-error #f (current-error-port) args)
|
|
||||||
(exit 1))))))
|
|
||||||
|
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
|
|
18
guix/ui.scm
18
guix/ui.scm
|
@ -47,6 +47,7 @@
|
||||||
P_
|
P_
|
||||||
report-error
|
report-error
|
||||||
leave
|
leave
|
||||||
|
report-load-error
|
||||||
show-version-and-exit
|
show-version-and-exit
|
||||||
show-bug-report-information
|
show-bug-report-information
|
||||||
string->number*
|
string->number*
|
||||||
|
@ -130,6 +131,23 @@ messages."
|
||||||
(report-error args ...)
|
(report-error args ...)
|
||||||
(exit 1)))
|
(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)
|
(define (install-locale)
|
||||||
"Install the current locale settings."
|
"Install the current locale settings."
|
||||||
(catch 'system-error
|
(catch 'system-error
|
||||||
|
|
Loading…
Reference in New Issue