Skip to content

Commit

Permalink
Added exception handling to pinpoint errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
malcolmsparks committed Jun 15, 2011
1 parent 3a2f73a commit 1bd895e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main/clojure/clj_markdown/core.clj
Expand Up @@ -35,13 +35,20 @@ cause the process to run infinitely."
(let [new-state (assoc state :line line :remaining rem)
new-state-tidied (dissoc new-state :yield)]
(if (nil? line) (assoc (process-eof proc new-state-tidied) :end true)
(process-line proc new-state-tidied))))]
(try
(process-line proc new-state-tidied)
(catch AssertionError e (throw (Exception. (format "Assertion failed, state was %s" (dissoc new-state-tidied :remaining)) e)))
(catch Exception e (throw (Exception. (format "Assertion failed, state was %s" (dissoc new-state-tidied :remaining)) e)))))))]
(iterate step {:remaining lines})))]
(concat yields (list (first eofs)))))

(defn filter-yields [states]
(filter #(not (nil? %)) (map :yield states)))

(defn line? [x]
(and (map? x)
(every? #(contains? x %) [:value :leading :trailing :empty])))

(defn read-markdown-lines [reader]
(letfn [
(space? [x] (= (int x) 32))
Expand Down

0 comments on commit 1bd895e

Please sign in to comment.