From 30290970b8a4e2da9b7e37daaebc349b050e2cc8 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sat, 24 Oct 2020 13:50:34 +0100 Subject: Add the ability to ignore errors when retrying As this will enable responding to some exceptions at a higher level. --- guix-build-coordinator/utils.scm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/guix-build-coordinator/utils.scm b/guix-build-coordinator/utils.scm index 5048d29..f12cab0 100644 --- a/guix-build-coordinator/utils.scm +++ b/guix-build-coordinator/utils.scm @@ -374,10 +374,20 @@ References: ~a~%" (canonical-sexp->string (signed-string info))))) (format #f "~aSignature: 1;~a;~a~%" info (gethostname) signature))) -(define* (retry-on-error f #:key times delay) +(define* (retry-on-error f #:key times delay ignore) (let loop ((attempt 1)) (match (with-exception-handler (lambda (exn) + (when (cond + ((list? ignore) + (any (lambda (test) + (test exn)) + ignore)) + ((procedure? ignore) + (ignore exn)) + (else #f)) + (raise-exception exn)) + (cons #f exn)) (lambda () (cons #t (f))) -- cgit v1.2.3