aboutsummaryrefslogtreecommitdiff
path: root/guix/store.scm
diff options
context:
space:
mode:
Diffstat (limited to 'guix/store.scm')
-rw-r--r--guix/store.scm27
1 files changed, 19 insertions, 8 deletions
diff --git a/guix/store.scm b/guix/store.scm
index 12f66d0e71..6c7c07fd2d 100644
--- a/guix/store.scm
+++ b/guix/store.scm
@@ -624,14 +624,25 @@ connection. Use with care."
(define (call-with-store proc)
"Call PROC with an open store connection."
(let ((store (open-connection)))
- (dynamic-wind
- (const #f)
- (lambda ()
- (parameterize ((current-store-protocol-version
- (store-connection-version store)))
- (proc store)))
- (lambda ()
- (false-if-exception (close-connection store))))))
+ (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;