                        (print value))))))]
          (comp/with-core-cljs opts
            (fn []
-             (when analyze-path
-               (analyze-source analyze-path opts))
-             (evaluate-form repl-env env "<cljs repl>"
-               (with-meta
-                 '(ns cljs.user
-                    (:require [cljs.repl :refer-macros [doc]]))
-                 {:line 1 :column 1})
-               identity opts)
+             (try
+               (when analyze-path
+                 (analyze-source analyze-path opts))
+               (evaluate-form repl-env env "<cljs repl>"
+                 (with-meta
+                   '(ns cljs.user
+                      (:require [cljs.repl :refer-macros [doc]]))
+                   {:line 1 :column 1})
+                 identity opts)
+               (catch Throwable e
+                 (caught e repl-env opts)))
              (when-let [src (:watch opts)]
                (future
                  (let [log-file (io/file (util/output-directory opts) "watch.log")]
                    (print "Watch compilation log available at:" (str log-file))
-                   (binding [*out* (FileWriter. log-file)]
-                     (cljsc/watch src (dissoc opts :watch))))))
+                   (try
+                     (binding [*out* (FileWriter. log-file)]
+                       (cljsc/watch src (dissoc opts :watch)))
+                     (catch Throwable e
+                       (caught e repl-env opts))))))
              (binding [*in* (if (true? (:source-map-inline opts))
                               *in*
                               (reader))]
                (try
                  (init)
                  (catch Throwable e
-                   (caught e opts)))
+                   (caught e repl-env opts)))
+               ;; try to let things flush before printing prompt
                (prompt)
                (flush)
                (loop []

             is-special-fn? (set (keys special-fns))
             request-prompt (Object.)
             request-exit (Object.)
             opts (if-let [merge-opts (:merge-opts (-setup repl-env opts))]
                    (merge opts merge-opts)
                    opts)
             read-eval-print
             (fn []
               (let [input (binding [*ns* (create-ns ana/*cljs-ns*)

(defn repl-prompt []
  (print (str "ClojureScript:" ana/*cljs-ns* "> ")))

(defn repl-caught [e repl-env opts]
  (if (and (instance? IExceptionInfo e)
           (#{:js-eval-error :js-eval-exception} (:type (ex-data e))))
    (let [{:keys [type repl-env error form js]} (ex-data e)]
