added scribble-exn->string

original commit: a29f37f18b19e8a87f01fb4da147c8c30eee788b
This commit is contained in:
Robby Findler 2013-03-20 21:18:47 -05:00
parent b50c8a7f6a
commit 04a6e274f9
2 changed files with 18 additions and 3 deletions

View File

@ -30,6 +30,7 @@
make-eval-factory
close-eval
scribble-exn->string
scribble-eval-handler)
(define scribble-eval-handler
@ -242,9 +243,7 @@
(define (do-ev s)
(with-handlers ([(lambda (x) (not (exn:break? x)))
(lambda (e)
(cons (if (exn? e)
(exn-message e)
(format "uncaught exception: ~s" e))
(cons ((scribble-exn->string) e)
(get-outputs)))])
(cons (render-value (do-plain-eval ev s #t)) (get-outputs))))
(define (do-ev/expect s expect)
@ -264,6 +263,13 @@
(list (list (void)) "" "")
(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,
;; copy each value to avoid side-effects.
(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
@racket[#t] if exceptions are being captured (to display exception
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)))]
}