Update render.rkt

rely on default exception messages, which are informative
pull/253/head
Matthew Butterick 4 years ago committed by GitHub
parent 4e8da0faf1
commit b2ac080927
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -234,19 +234,18 @@
(define ram-cache (make-hash)) (define ram-cache (make-hash))
(define (get-external-render-proc v) (define (get-external-render-proc v)
(cond (match v
[(and (list? v) [(list (? module-path? mod) (? symbol? render-proc-id))
(eq? 2 (length v))
(module-path? (first v))
(symbol? (second v)))
(let ([mod (first v)]
[render-proc-id (second v)])
(with-handlers ([exn:fail:filesystem:missing-module? (with-handlers ([exn:fail:filesystem:missing-module?
(lambda (e) (error 'external-renderer "cannot open module ~a" mod))]) (λ (e) (raise
(dynamic-require mod (exn:fail:contract (string-replace (exn-message e) "standard-module-name-resolver" "external-renderer")
render-proc-id (exn-continuation-marks e))))]
(lambda () (error 'external-renderer "~a is not provided by ~a" render-proc-id mod)))))] [exn:fail:contract? ;; raised if dynamic-require can't find render-proc-id
[else (error 'setup:external-renderer "Value is not in the form '(module-path proc-id): ~v" v)])) (λ (e) (raise
(exn:fail:contract (string-replace (exn-message e) "dynamic-require" "external-renderer")
(exn-continuation-marks e))))])
(dynamic-require mod render-proc-id))]
[_ (raise-argument-error 'external-renderer "value in the form '(module-path proc-id)" v)]))
;; note that output and template order is reversed from typical ;; note that output and template order is reversed from typical
(define (render-to-file-base caller (define (render-to-file-base caller

Loading…
Cancel
Save