pkg/lib: add #:package-exn-handler to pkg-catalog-archive

This commit is contained in:
Matthew Flatt 2014-06-30 09:18:38 +01:00
parent 646b836183
commit 22f90ce8fe
2 changed files with 68 additions and 54 deletions

View File

@ -368,15 +368,24 @@ for extracting existing catalog information.
[#:from-config? from-config? boolean? #f]
[#:state-catalog state-catalog (or/c #f path-string?) #f]
[#:relative-sources? relative-sources? boolean? #f]
[#:quiet? quiet? boolean? #f])
[#:quiet? quiet? boolean? #f]
[#:package-exn-handler package-exn-handler (string? exn:fail? . -> . any) (lambda (_pkg-name _exn) (raise _exn))])
void?]{
Implements @racket[pkg-catalog-archive-command].
The @racket[package-exn-handler] argument handles any exception that
is raised while trying to archive an individual package; the first
argument is the package name, and the second is the exception. The
default re-@racket[raise]s the exception, which aborts the archiving
process, while a function that logs the exception message and returns
would allow archiving to continue for other packages.
The @racket[current-pkg-lookup-version] parameter determines the version
for extracting existing catalog information.
@history[#:added "6.0.1.7"]}
@history[#:added "6.0.1.7"
#:changed "6.0.1.13" @elem{Added the @racket[#:package-exn-handler] argument.}]}
@defproc[(pkg-catalog-update-local [#:catalogs catalogs (listof string?) (pkg-config-catalogs)]

View File

@ -3175,7 +3175,8 @@
#:set-catalogs? [set-catalogs? #t]
#:catalog-file [catalog-file (db:current-pkg-catalog-file)]
#:quiet? [quiet? #f]
#:consult-packages? [consult-packages? #f])
#:consult-packages? [consult-packages? #f]
#:skip-download-failures? [skip-download-failures? #f])
(parameterize ([db:current-pkg-catalog-file catalog-file])
(define current-catalogs (db:get-catalogs))
(cond
@ -3242,7 +3243,8 @@
#:from-config? [from-config? #f]
#:state-catalog [state-catalog #f]
#:relative-sources? [relative-sources? #f]
#:quiet? [quiet? #f])
#:quiet? [quiet? #f]
#:package-exn-handler [package-exn-handler (lambda (name exn) (raise exn))])
(when (and state-catalog
(not (db-path? (if (path? state-catalog)
state-catalog
@ -3281,6 +3283,8 @@
;; Check on each new package:
(for ([pkg (in-list (sort pkgs string<? #:key db:pkg-name))])
(define name (db:pkg-name pkg))
(with-handlers ([exn:fail? (lambda (exn)
(package-exn-handler name exn))])
(define current-checksum (and state-catalog
(parameterize ([db:current-pkg-catalog-file state-catalog])
(define l (db:get-pkgs #:name (db:pkg-name pkg)))
@ -3330,7 +3334,7 @@
modules)
(db:set-pkg-dependencies! name (db:pkg-catalog pkg)
new-checksum
dependencies)))
dependencies))))
(define dest-catalog (build-path dest-dir "catalog"))
(unless quiet?
(printf/flush "Creating catalog ~a\n" dest-catalog))
@ -3495,7 +3499,8 @@
(#:from-config? boolean?
#:state-catalog (or/c path-string? #f)
#:relative-sources? boolean?
#:quiet? boolean?)
#:quiet? boolean?
#:package-exn-handler (string? exn:fail? . -> . any))
void?)]
[default-pkg-scope
(-> package-scope/c)]