From 09eb2cc7b74e051161bb111eb52fd9a932bd64a6 Mon Sep 17 00:00:00 2001
From: Eli Barzilay <eli@barzilay.org>
Date: Thu, 16 Jun 2011 07:07:13 -0400
Subject: [PATCH] Add an error message when the sandbox doesn't capture its
 output as a string.

original commit: 43d1c240a171943e214ac43055e6bdbfc5072f70
---
 collects/scribble/eval.rkt | 41 +++++++++++++++++++-------------------
 1 file changed, 20 insertions(+), 21 deletions(-)

diff --git a/collects/scribble/eval.rkt b/collects/scribble/eval.rkt
index 006e57af..90519aa8 100644
--- a/collects/scribble/eval.rkt
+++ b/collects/scribble/eval.rkt
@@ -57,27 +57,26 @@
           (make-element style (list s)))))
 
   (define (format-output str style)
-    (if (string=? "" str)
-        null
+    (cond
+      [(not (string? str))
+       (error 'format-output "missing output, possibly from a sandbox ~a"
+              "without a `sandbox-output' configured to 'string")]
+      [(string=? "" str) null]
+      [else
+       (list
         (list
-         (list
-          (make-flow 
-           (list
-            (let ([s (regexp-split #rx"\n"
-                                   (regexp-replace #rx"\n$"
-                                                   str
-                                                   ""))])
-              (if (= 1 (length s))
-                  (make-paragraph
-                   (list
-                    (literal-string style (car s))))
-                  (make-table
-                   #f
-                   (map (lambda (s)
-                          (list (make-flow (list (make-paragraph
-                                                  (list
-                                                   (literal-string style s)))))))
-                        s))))))))))
+         (make-flow
+          (list
+           (let ([s (regexp-split #rx"\n" (regexp-replace #rx"\n$" str ""))])
+             (if (= 1 (length s))
+               (make-paragraph (list (literal-string style (car s))))
+               (make-table
+                #f
+                (map (lambda (s)
+                       (list (make-flow
+                              (list (make-paragraph
+                                     (list (literal-string style s)))))))
+                     s))))))))]))
 
     (define (format-output-stream in style)
       (define (add-string string-accum line-accum)
@@ -257,7 +256,7 @@
                   (raise-syntax-error 'eval "example result check failed" s))))
             r)
           (values (list (list (void)) "" "")))))
-                   
+
 
   (define (install ht v v2)
     (hash-set! ht v v2)