Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions src/special/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,23 @@
c must be a keyword."
[condition & [value & {:as handlers}]]
(assert (and (keyword? condition) (not (#{:trace} condition))))
(let [get-h (fn [m k] (if (contains? m k)
(let [h (m k)]
(case h
nil ::nil
false ::false
h))))
(let [get-h #(when (contains? % %2)
(let [x (% %2)]
(case x
nil ::nil
false ::false
x)))
x (or (get-h *-special-condition-handlers-* condition)
(get-h handlers :normally)
(throw (ex-info (str "Unhandled condition " condition)
{::condition condition
:value value})))]
(cond (fn? x) ((if (seq handlers)
(apply manage x (apply concat handlers))
x)
value)
(= ::nil x) nil
(= ::false x) false
:else x)))
(case x
::nil nil
::false false
(if (fn? x)
((if (seq handlers)
(apply manage x (apply concat handlers))
x)
value)
x))))