racket/enter: another submodule repair

When a submodule is required from the load handler and no such
module is available, the load handler is not supposed to raise
an exception.
This commit is contained in:
Matthew Flatt 2013-02-14 19:44:03 -07:00
parent b22ac3b990
commit 6a218e196a

View File

@ -15,6 +15,8 @@
(define orig-namespace (current-namespace))
(define-logger enter!)
(define (check-flags flags)
;; check that all flags are known, that at most one of the noise flags is
;; present, and add #:verbose-reload if none are (could be done at the macro
@ -34,7 +36,8 @@
(let ([flags (check-flags flags)])
(if mod
(let* ([none "none"]
[exn (with-handlers ([void values])
[exn (with-handlers ([void (lambda (exn)
(log-enter!-error "~a" (exn-message exn)))])
(enter-require mod flags)
none)]
[ns (module->namespace mod)])
@ -68,6 +71,13 @@
(not (and (pair? name)
(not (car name)))))
;; Module load:
(with-handlers ([(lambda (exn)
(and (pair? name)
(exn:get-module-code? exn)))
(lambda (exn)
;; Load-handler protocol: quiet failure when a
;; submodule is not found
(void))])
(let* ([code (get-module-code
path "compiled"
(lambda (e)
@ -88,7 +98,7 @@
(hash-set! loaded path a-mod))
;; Evaluate the module:
(parameterize ([current-module-declare-source actual-path])
(eval code)))
(eval code))))
;; Not a module, or a submodule that we shouldn't load from source:
(begin (notify path) (orig path name)))))