   org.jruby.exceptions.RaiseException [e]
   (.getException e))
 
+;; Exceptions aren't IRubyObjects
 (defmethod ->ruby
   java.lang.Exception [e]
-  e)
+  (let [w (StringWriter.)
+        pw (PrintWriter. w)]
+    (.printStackTrace e pw)
+    (.toString w)))
 
 (defmethod ->ruby
   clojure.lang.Sequential [v]

(ns circle.ruby
  (:refer-clojure :exclude [eval send methods])
  (:import org.jruby.RubySymbol)
  (:import java.lang.ref.WeakReference)
  (:use [circle.util.except :only (throw-if-not)])
  (:require fs))

(defmethod ->ruby
  nil [n]
  (-> (ruby) (.getNil)))

(defmethod ->ruby
  :default [val]
  (org.jruby.RubyString/newString (ruby) (format "Uncastable values: %s" val)))

(def sample-objectid-string "4ee6911fe4b05e6a4d3605fe")

