[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
05/21: import: utils: 'call-with-networking-exception-handler' doesn't u
From: |
guix-commits |
Subject: |
05/21: import: utils: 'call-with-networking-exception-handler' doesn't unwind. |
Date: |
Wed, 31 May 2023 17:52:48 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit 4663cfd381e278747b28bbb7aebe45ab76e8c984
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Mon May 15 22:52:25 2023 +0200
import: utils: 'call-with-networking-exception-handler' doesn't unwind.
That way backtraces show where the error actually originates from.
* guix/import/utils.scm (call-with-networking-exception-handler):
Rewrite using 'with-exception-handler'.
---
guix/import/utils.scm | 33 +++++++++++++++++++++------------
1 file changed, 21 insertions(+), 12 deletions(-)
diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index 177817b10c..e9a0a7ecd7 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -45,6 +45,7 @@
#:use-module (guix sets)
#:use-module ((guix ui) #:select (fill-paragraph))
#:use-module (gnu packages)
+ #:autoload (ice-9 control) (let/ec)
#:use-module (ice-9 match)
#:use-module (ice-9 rdelim)
#:use-module (ice-9 receive)
@@ -126,18 +127,26 @@ of the string VERSION is replaced by the symbol 'version."
(define (call-with-networking-exception-handler thunk)
"Invoke THUNK, returning #f if one of the usual networking exception is
thrown."
- (catch #t
- (lambda ()
- (guard (c ((http-get-error? c) #f))
- (thunk)))
- (lambda (key . args)
- ;; Return false and move on upon connection failures and bogus HTTP
- ;; servers.
- (unless (memq key '(gnutls-error tls-certificate-error
- system-error getaddrinfo-error
- bad-header bad-header-component))
- (apply throw key args))
- #f)))
+ (let/ec return
+ (with-exception-handler
+ (lambda (exception)
+ (cond ((http-get-error? exception)
+ (return #f))
+ (((exception-predicate &exception-with-kind-and-args)
exception)
+ ;; Return false and move on upon connection failures and bogus
+ ;; HTTP servers.
+ (if (memq (exception-kind exception)
+ '(gnutls-error tls-certificate-error
+ system-error getaddrinfo-error
+ bad-header bad-header-component))
+ (return #f)
+ (raise-exception exception)))
+ (else
+ (raise-exception exception))))
+ thunk
+
+ ;; Do not unwind to preserve meaningful backtraces.
+ #:unwind? #f)))
(define-syntax-rule (false-if-networking-error exp)
"Evaluate EXP, returning #f if a networking-related exception is thrown."
- 08/21: upstream: Replace 'input-changes' field by 'inputs'., (continued)
- 08/21: upstream: Replace 'input-changes' field by 'inputs'., guix-commits, 2023/05/31
- 02/21: tests: pypi: Factorize tarball and wheel file creation., guix-commits, 2023/05/31
- 09/21: diagnostics: Factorize 'absolute-location'., guix-commits, 2023/05/31
- 07/21: doc: Mention 'guix refresh -u' for third-party channels., guix-commits, 2023/05/31
- 11/21: upstream: Remove <upstream-input-change> and related code., guix-commits, 2023/05/31
- 10/21: upstream: 'update-package-source' edits input fields., guix-commits, 2023/05/31
- 12/21: tests: upstream: Restore test that was skipped., guix-commits, 2023/05/31
- 16/21: import: elpa: Updater provides input list., guix-commits, 2023/05/31
- 20/21: gnu: Add updater input properties for R and Python packages., guix-commits, 2023/05/31
- 21/21: tests: Use quasiquoted 'match' patterns for package sexps., guix-commits, 2023/05/31
- 05/21: import: utils: 'call-with-networking-exception-handler' doesn't unwind.,
guix-commits <=
- 04/21: tests: pypi: Rewrite tests using a local HTTP server., guix-commits, 2023/05/31
- 14/21: import: cpan: Represent dependencies as <upstream-input> records., guix-commits, 2023/05/31
- 15/21: import: cpan: Updater provides input list., guix-commits, 2023/05/31
- 19/21: upstream: Honor package properties for ignored and extra inputs., guix-commits, 2023/05/31
- 13/21: import: cpan: Remove unary 'string-append' call., guix-commits, 2023/05/31
- 18/21: import: gem: Updater provides input list., guix-commits, 2023/05/31
- 03/21: tests: http: Allow responses to specify a path., guix-commits, 2023/05/31
- 17/21: import: gem: Factorize "bundler" special case for name mapping., guix-commits, 2023/05/31