throw error if function names incorrectly specified in defpath, improve formatting of error messages

This commit is contained in:
Nathan Marz 2016-01-05 08:57:27 -05:00
parent b10c1f82ff
commit 0f3ea6c79b
2 changed files with 12 additions and 1 deletions

View file

@ -23,9 +23,17 @@
(defprotocol PathComposer
(comp-paths* [paths]))
(defn- smart-str* [o]
(if (coll? o)
(pr-str o)
(str o)))
(defn smart-str [& elems]
(apply str (map smart-str* elems)))
#+clj
(defmacro throw* [etype & args]
`(throw (new ~etype (pr-str ~@args))))
`(throw (new ~etype (smart-str ~@args))))
#+clj
(defmacro throw-illegal [& args]

View file

@ -6,6 +6,9 @@
(vec (repeatedly amt gensym)))
(defn determine-params-impls [[name1 & impl1] [name2 & impl2]]
(if-not (= #{name1 name2} #{'select* 'transform*})
(throw-illegal "defpath must implement select* and transform*, instead got "
name1 " and " name2))
(if (= name1 'select*)
[impl1 impl2]
[impl2 impl1]))