Skip to content

Commit

Permalink
handle messages with malformed code
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveWM committed Dec 12, 2018
1 parent 03dddc6 commit 972997f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/nrepl_rebl/core.clj
Expand Up @@ -24,7 +24,9 @@

(defn read-string* [s]
(when s
(read-string s)))
(try
(read-string s)
(catch Exception e nil))))


(defrecord ReblTransport [transport handler-msg]
Expand All @@ -33,7 +35,7 @@
(transport/recv transport timeout))
(send [this {:keys [value] :as msg}]
(transport/send transport msg)
(let [code-form (read-string* (:code handler-msg))]
(when-let [code-form (read-string* (:code handler-msg))]
(when (and (some? value)
(not (form-from-cursive? code-form)))
(rebl/submit code-form value)))
Expand Down
4 changes: 3 additions & 1 deletion test/nrepl_rebl/core_test.clj
Expand Up @@ -12,7 +12,9 @@

(deftest read-string*-test
(is (nil? (read-string* nil)))
(is 1 (read-string* "1")))
(is 1 (read-string* "1"))
(is (nil? (read-string* "")))
(is (nil? (read-string* "(+ 1"))))


(deftest wrap-rebl-has-meta
Expand Down

0 comments on commit 972997f

Please sign in to comment.