Skip to content

Commit

Permalink
Handle init-ns compile errors more gracefully
Browse files Browse the repository at this point in the history
refs #106
  • Loading branch information
trptcolin committed Mar 23, 2013
1 parent 92a3dce commit a8ca026
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/clj/reply/eval_modes/nrepl.clj
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,24 @@
(list "")))))
(list request-exit)))

(defn- handle-ns-init-error [ns connection options]
(if (= ns "reply.eval-modes.nrepl")
(let [fallback-ns
(execute-with-client
connection options
"(in-ns 'user)
(println \"\\nError loading namespace; falling back to user\")")]
(println)
fallback-ns)
ns))

(defn run-repl
([connection] (run-repl connection nil))
([connection {:keys [prompt] :as options}]
(let [{:keys [major minor incremental qualifier]} *clojure-version*]
(loop [ns (execute-with-client connection options "")]
(let [eof (Object.)
(let [ns (handle-ns-init-error ns connection options)
eof (Object.)
execute (partial execute-with-client connection
(assoc options :interactive true))
forms (parsed-forms {:request-exit eof
Expand Down

0 comments on commit a8ca026

Please sign in to comment.