Commits

Miki Tebeka  committed 2fb7c2c

wrapped-expr

  • Participants
  • Parent commits a9997aa

Comments (0)

Files changed (1)

File src/dr/evil.clj

 (ns dr.evil
   (:use compojure.core)
   (:use ring.util.response)
+  (:use [clojure.stacktrace :only (print-stack-trace)])
   (:use [clojure.contrib.json :only (json-str)]))
 
 (defn input-page []
   (slurp "src/index.html"))
 
+; FIXME: Give use ability to change namespace
+(defn wrapped-expr [expr]
+  (str "(binding [*print-length* 100] (do (in-ns 'dr.evil) " expr "))"))
+
 (defn eval-expr [expr]
   (try
-    (let [result (load-string (str "(in-ns 'dr.evil) " expr))]
+    (let [result (load-string (wrapped-expr expr))]
       { :result (with-out-str (println result)) :error false })
     (catch Exception e
-      (let [result (with-out-str (.printStackTrace e))]
+      (let [result (with-out-str (print-stack-trace e))]
         { :result result :error true }))))
 
 (defn evil [params]