From 7ce81abe9ffd7d0e86b31c4eca840efc805c5669 Mon Sep 17 00:00:00 2001 From: oakes Date: Sat, 23 Aug 2014 22:20:30 -0400 Subject: [PATCH] Improve error message when passing invalid defscreen args --- src/play_clj/core.clj | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/play_clj/core.clj b/src/play_clj/core.clj index 926191b..f399d16 100644 --- a/src/play_clj/core.clj +++ b/src/play_clj/core.clj @@ -465,8 +465,15 @@ via the screen map. (println (:initial-distance screen)) ; the start distance between fingers (println (:distance screen)) ; the end distance between fingers entities))" - [n & {:keys [] :as options}] - `(let [fn-syms# (->> (for [[k# v#] ~options] + [n & options] + ; make sure the options are valid + (let [s (format "Unexpected value in (defscreen %s). Make sure you give it +keywords and functions in pairs." + (str n))] + (assert (even? (count options)) s) + (assert (= 0 (count (remove keyword? (keys (apply hash-map options))))) s)) + ; return form calling defscreen* + `(let [fn-syms# (->> (for [[k# v#] ~(apply hash-map options)] [k# (intern *ns* (symbol (str '~n "-" (name k#))) v#)]) flatten (apply hash-map))