added scribble-exn->string

This commit is contained in:
Robby Findler 2013-03-20 21:18:47 -05:00
parent 2792cd7b5f
commit a29f37f18b
2 changed files with 18 additions and 3 deletions

View File

@ -30,6 +30,7 @@
make-eval-factory make-eval-factory
close-eval close-eval
scribble-exn->string
scribble-eval-handler) scribble-eval-handler)
(define scribble-eval-handler (define scribble-eval-handler
@ -242,9 +243,7 @@
(define (do-ev s) (define (do-ev s)
(with-handlers ([(lambda (x) (not (exn:break? x))) (with-handlers ([(lambda (x) (not (exn:break? x)))
(lambda (e) (lambda (e)
(cons (if (exn? e) (cons ((scribble-exn->string) e)
(exn-message e)
(format "uncaught exception: ~s" e))
(get-outputs)))]) (get-outputs)))])
(cons (render-value (do-plain-eval ev s #t)) (get-outputs)))) (cons (render-value (do-plain-eval ev s #t)) (get-outputs))))
(define (do-ev/expect s expect) (define (do-ev/expect s expect)
@ -264,6 +263,13 @@
(list (list (void)) "" "") (list (list (void)) "" "")
(do-ev/expect s expect)))))) (do-ev/expect s expect))))))
(define scribble-exn->string
(make-parameter
(λ (e)
(if (exn? e)
(exn-message e)
(format "uncaught exception: ~s" e)))))
;; Since we evaluate everything in an interaction before we typeset, ;; Since we evaluate everything in an interaction before we typeset,
;; copy each value to avoid side-effects. ;; copy each value to avoid side-effects.
(define (copy-value v ht) (define (copy-value v ht)

View File

@ -196,3 +196,12 @@ is supplied as the first argument to the parameter's value, and the
second argument is the form to evaluate. The last argument is second argument is the form to evaluate. The last argument is
@racket[#t] if exceptions are being captured (to display exception @racket[#t] if exceptions are being captured (to display exception
results), @racket[#f] otherwise.} results), @racket[#f] otherwise.}
@defparam[scribble-exn->string handler (-> (or/c exn? any/c) string?)]{
A parameter that controls how exceptions are rendered by
@racket[interaction]. Defaults to
@racketblock[(λ (e)
(if (exn? e)
(exn-message e)
(format "uncaught exception: ~s" e)))]
}