ui: Always print the exception upon load errors.

Fixes <https://bugs.gnu.org/34402>.
Reported by <pkill9@runbox.com>.

Previously 'display-error' could be called with the wrong number of
arguments (e.g., for 'git-error' exceptions), and thus nothing at all
was displayed.

* guix/ui.scm (report-load-error): Check whether ARGS matches the
parameters for 'display-error' and call 'print-exception' otherwise.
This commit is contained in:
Ludovic Courtès 2019-02-11 22:48:24 +01:00
parent 5ea206a8a9
commit 70a50305c4
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 9 additions and 2 deletions

View File

@ -374,9 +374,16 @@ ARGS is the list of arguments received by the 'throw' handler."
(report-error (G_ "exception thrown: ~s~%") obj)) (report-error (G_ "exception thrown: ~s~%") obj))
(when (fix-hint? obj) (when (fix-hint? obj)
(display-hint (condition-fix-hint obj)))) (display-hint (condition-fix-hint obj))))
((error args ...) ((key args ...)
(report-error (G_ "failed to load '~a':~%") file) (report-error (G_ "failed to load '~a':~%") file)
(apply display-error frame (current-error-port) args)))) (match args
(((? symbol? proc) (? string? message) (args ...) . rest)
(display-error frame (current-error-port) proc message
args rest))
(_
;; Some exceptions like 'git-error' do not follow Guile's convention
;; above and need to be printed with 'print-exception'.
(print-exception (current-error-port) frame key args))))))
(define (warn-about-load-error file args) ;FIXME: factorize with ↑ (define (warn-about-load-error file args) ;FIXME: factorize with ↑
"Report the failure to load FILE, a user-provided Scheme file, without "Report the failure to load FILE, a user-provided Scheme file, without