diff options
-rw-r--r-- | guix/store.scm | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/guix/store.scm b/guix/store.scm index 1dd5c9545b..fb4b92e0c4 100644 --- a/guix/store.scm +++ b/guix/store.scm @@ -623,16 +623,25 @@ connection. Use with care." (define (call-with-store proc) "Call PROC with an open store connection." (let ((store (open-connection))) - (catch #t - (lambda () - (parameterize ((current-store-protocol-version - (store-connection-version store))) - (let ((result (proc store))) - (close-connection store) - result))) - (lambda (key . args) - (close-connection store) - (apply throw key args))))) + (define (thunk) + (parameterize ((current-store-protocol-version + (store-connection-version store))) + (let ((result (proc store))) + (close-connection store) + result))) + + (cond-expand + (guile-3 + (with-exception-handler (lambda (exception) + (close-connection store) + (raise-exception exception)) + thunk)) + (else ;Guile 2.2 + (catch #t + thunk + (lambda (key . args) + (close-connection store) + (apply throw key args))))))) (define-syntax-rule (with-store store exp ...) "Bind STORE to an open connection to the store and evaluate EXPs; |