diff --git a/src/clj/com/rpl/specter/impl.cljx b/src/clj/com/rpl/specter/impl.cljx index d78627d..84b592f 100644 --- a/src/clj/com/rpl/specter/impl.cljx +++ b/src/clj/com/rpl/specter/impl.cljx @@ -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] diff --git a/src/clj/com/rpl/specter/macros.clj b/src/clj/com/rpl/specter/macros.clj index b25738a..a8d5141 100644 --- a/src/clj/com/rpl/specter/macros.clj +++ b/src/clj/com/rpl/specter/macros.clj @@ -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]))