summaryrefslogtreecommitdiff
path: root/guix/scripts
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2016-05-17 13:41:07 +0200
committerLudovic Courtès <ludo@gnu.org>2016-05-17 14:02:48 +0200
commit149590380adb240e0993931b4f72e6f285b24483 (patch)
tree674e6a742eb21d714eb2eee00eec87273e7e273e /guix/scripts
parent787afdd0f1ce1d4aa7500d858f2635462b444699 (diff)
import: Gracefully report import failures.
Previously, something like 'guix import gnu which' would spit out a backtrace if, say, the 'which' tarball could not be authenticated. * guix/upstream.scm (download-tarball): Mention failure modes in docstring. * guix/import/gnu.scm (gnu-package->sexp): Return #f when 'download-tarball' returns #f. * guix/scripts/import.scm (guix-import): Call 'leave' when IMPORTER does not return a (package ...) sexp.
Diffstat (limited to 'guix/scripts')
-rw-r--r--guix/scripts/import.scm8
1 files changed, 6 insertions, 2 deletions
diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
index cf8fc073b2..e54744feca 100644
--- a/guix/scripts/import.scm
+++ b/guix/scripts/import.scm
@@ -107,6 +107,10 @@ Run IMPORTER with ARGS.\n"))
(show-version-and-exit "guix import"))
((importer args ...)
(if (member importer importers)
- (let ((expr (apply (resolve-importer importer) args)))
- (pretty-print expr (newline-rewriting-port (current-output-port))))
+ (match (apply (resolve-importer importer) args)
+ ((and expr ('package _ ...))
+ (pretty-print expr (newline-rewriting-port
+ (current-output-port))))
+ (x
+ (leave (_ "'~a' import failed~%") importer)))
(leave (_ "~a: invalid importer~%") importer)))))