diff --git a/guix/nar.scm b/guix/nar.scm index 6beda91c02..0a7187c2dd 100644 --- a/guix/nar.scm +++ b/guix/nar.scm @@ -370,7 +370,7 @@ (define (assert-valid-signature signature hash file) (let ((signature (catch 'gcry-error (lambda () (string->canonical-sexp signature)) - (lambda (err . _) + (lambda (key proc err) (raise (condition (&message (message "signature is not a valid \ diff --git a/guix/pk-crypto.scm b/guix/pk-crypto.scm index 351bf929c5..71104128c1 100644 --- a/guix/pk-crypto.scm +++ b/guix/pk-crypto.scm @@ -143,7 +143,7 @@ (define string->canonical-sexp (err (proc sexp (string->pointer str "ISO-8859-1") 0 1))) (if (= 0 err) (pointer->canonical-sexp (dereference-pointer sexp)) - (throw 'gcry-error err)))))) + (throw 'gcry-error 'string->canonical-sexp err)))))) (define-syntax GCRYSEXP_FMT_ADVANCED (identifier-syntax 3)) @@ -296,7 +296,7 @@ (define sign (canonical-sexp->pointer secret-key)))) (if (= 0 err) (pointer->canonical-sexp (dereference-pointer sig)) - (throw 'gry-error err)))))) + (throw 'gcry-error 'sign err)))))) (define verify (let* ((ptr (libgcrypt-func "gcry_pk_verify")) @@ -318,7 +318,7 @@ (define generate-key (err (proc key (canonical-sexp->pointer params)))) (if (zero? err) (pointer->canonical-sexp (dereference-pointer key)) - (throw 'gcry-error err)))))) + (throw 'gcry-error 'generate-key err)))))) (define find-sexp-token (let* ((ptr (libgcrypt-func "gcry_sexp_find_token")) @@ -403,4 +403,13 @@ (define (write item) (write sexp))))) +(define (gcrypt-error-printer port key args default-printer) + "Print the gcrypt error specified by ARGS." + (match args + ((proc err) + (format port "In procedure ~a: ~a: ~a" + proc (error-source err) (error-string err))))) + +(set-exception-printer! 'gcry-error gcrypt-error-printer) + ;;; pk-crypto.scm ends here diff --git a/guix/scripts/archive.scm b/guix/scripts/archive.scm index 0a2e186da6..84904e29da 100644 --- a/guix/scripts/archive.scm +++ b/guix/scripts/archive.scm @@ -123,7 +123,7 @@ (define %options (string->canonical-sexp (or arg %key-generation-parameters)))) (alist-cons 'generate-key params result))) - (lambda (key err) + (lambda (key proc err) (leave (_ "invalid key generation parameters: ~a: ~a~%") (error-source err) (error-string err)))))) @@ -248,7 +248,7 @@ (define (generate-key-pair parameters) (let* ((pair (catch 'gcry-error (lambda () (generate-key parameters)) - (lambda (key err) + (lambda (key proc err) (leave (_ "key generation failed: ~a: ~a~%") (error-source err) (error-string err))))) @@ -275,7 +275,7 @@ (define (read-key) (catch 'gcry-error (lambda () (string->canonical-sexp (get-string-all (current-input-port)))) - (lambda (key err) + (lambda (key proc err) (leave (_ "failed to read public key: ~a: ~a~%") (error-source err) (error-string err))))) diff --git a/guix/scripts/substitute-binary.scm b/guix/scripts/substitute-binary.scm index 8e35612e3a..c70a4f626c 100755 --- a/guix/scripts/substitute-binary.scm +++ b/guix/scripts/substitute-binary.scm @@ -252,7 +252,7 @@ (define (narinfo-signature->canonical-sexp str) (catch 'gcry-error (lambda () (string->canonical-sexp signature)) - (lambda (err . rest) + (lambda (key proc err) (leave (_ "signature is not a valid \ s-expression: ~s~%") signature))))))))