Update render.rkt

rely on default exception messages, which are informative
pull/253/head
Matthew Butterick 3 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 (get-external-render-proc v)
(cond
[(and (list? v)
(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?
(lambda (e) (error 'external-renderer "cannot open module ~a" mod))])
(dynamic-require mod
render-proc-id
(lambda () (error 'external-renderer "~a is not provided by ~a" render-proc-id mod)))))]
[else (error 'setup:external-renderer "Value is not in the form '(module-path proc-id): ~v" v)]))
(match v
[(list (? module-path? mod) (? symbol? render-proc-id))
(with-handlers ([exn:fail:filesystem:missing-module?
(λ (e) (raise
(exn:fail:contract (string-replace (exn-message e) "standard-module-name-resolver" "external-renderer")
(exn-continuation-marks e))))]
[exn:fail:contract? ;; raised if dynamic-require can't find render-proc-id
(λ (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
(define (render-to-file-base caller

Loading…
Cancel
Save