From 390f2b35fcd7fc59b05225b302358aac016b6755 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 18 May 2023 17:03:08 +0200 Subject: [PATCH] :bug: Ensure verify! works as expected on production builds --- common/src/app/common/data/macros.cljc | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/common/src/app/common/data/macros.cljc b/common/src/app/common/data/macros.cljc index 5ee0151106..836656d938 100644 --- a/common/src/app/common/data/macros.cljc +++ b/common/src/app/common/data/macros.cljc @@ -153,6 +153,22 @@ (throw (ex-info hint# params#))))))))) (defmacro verify! - [& params] - (binding [*assert* true] - `(assert! ~@params))) + ([expr] + `(assert! nil ~expr)) + ([hint expr] + (let [hint (cond + (vector? hint) + `(str/ffmt ~@hint) + + (some? hint) + hint + + :else + (str "expr assert: " (pr-str expr)))] + `(binding [*assert-context* true] + (when-not ~expr + (let [hint# ~hint + params# {:type :assertion + :code :expr-validation + :hint hint#}] + (throw (ex-info hint# params#))))))))