     (uncaughtException [thread exception]
       (f thread exception))))
 
-(def debug-ex-handler (make-error-handler (fn [thread exception] (debug-repl))))
+(def debug-ex-handler (make-error-handler (fn [thread debug-exception] (debug-repl))))
 
 (defn debug-uncaught-exceptions! []
   (Thread/setDefaultUncaughtExceptionHandler debug-ex-handler))

  (throw quit-dr-exception))

(defn caught [exc]
  (if (= (.getCause ^Throwable exc) quit-dr-exception)
    (throw quit-dr-exception)
    (clojure.main/repl-caught exc)))

(defmacro debug-repl
  "Starts a REPL with the local bindings available."
  ([]
   `(debug-repl nil))
  ([form]
   `(let [counter# (inc-counter)
          eval-fn# (partial eval-with-locals (local-bindings))]
      (try
        (binding [level (inc level)]
          (clojure.main/repl
            :prompt #(print (str "dr-" level "-" counter# " => "))
            :eval eval-fn#
            :read dr-read
            :caught caught))
        (catch Exception e#
          (if (= e# quit-dr-exception)
            (if-let [new-form# (.nextElement quit-dr-exception)]
              (eval-fn# new-form#)
              (eval-fn# ~form))
            (throw e#)))))))

(defmacro assert-repl [assertion-form]

(defmacro try-repl [body-form]
  `(try
     ~body-form
     (catch Throwable ex#
       (let [~'debug-exception ex#]
         (debug-repl)))))

(defn make-error-handler
  "This takes a function that takes two args
