Permalink
Browse files

break out handling of a single message with a particular transport

  • Loading branch information...
1 parent b01a228 commit 16dc104da7b9cd0adcce74f91125464f6072fb26 @cemerick cemerick committed Mar 29, 2012
Showing with 9 additions and 5 deletions.
  1. +9 −5 src/main/clojure/clojure/tools/nrepl/server.clj
View
14 src/main/clojure/clojure/tools/nrepl/server.clj
@@ -15,16 +15,20 @@
[transport {:keys [op] :as msg}]
(t/send transport (response-for msg :status #{:error :unknown-op} :op op)))
+(defn handle*
+ [msg handler transport]
+ (try
+ (or (handler (assoc msg :transport transport))
+ (unknown-op transport msg))
+ (catch Throwable t
+ (log t "Unhandled REPL handler exception processing message" msg))))
+
(defn handle
"Handles requests received via `transport` using `handler`.
Returns nil when `recv` returns nil for the given transport."
[handler transport]
(when-let [msg (t/recv transport)]
- (try
- (or (handler (assoc msg :transport transport))
- (unknown-op transport msg))
- (catch Throwable t
- (log t "Unhandled REPL handler exception processing message" msg)))
+ (handle* msg handler transport)
(recur handler transport)))
(defn- accept-connection

0 comments on commit 16dc104

Please sign in to comment.