From 04a6e274f9a7afb859cb55c50cb6bd2df12ca269 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Wed, 20 Mar 2013 21:18:47 -0500 Subject: [PATCH] added scribble-exn->string original commit: a29f37f18b19e8a87f01fb4da147c8c30eee788b --- collects/scribble/eval.rkt | 12 +++++++++--- collects/scribblings/scribble/eval.scrbl | 9 +++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/collects/scribble/eval.rkt b/collects/scribble/eval.rkt index 033665b2..25ae2d60 100644 --- a/collects/scribble/eval.rkt +++ b/collects/scribble/eval.rkt @@ -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) diff --git a/collects/scribblings/scribble/eval.scrbl b/collects/scribblings/scribble/eval.scrbl index 014b38e4..e02bad0f 100644 --- a/collects/scribblings/scribble/eval.scrbl +++ b/collects/scribblings/scribble/eval.scrbl @@ -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)))] +}