mirror of
https://github.com/penpot/penpot.git
synced 2025-12-11 22:14:05 +01:00
✨ Improve invalid schema error report
This commit is contained in:
@@ -281,7 +281,20 @@
|
|||||||
(defn check-fn
|
(defn check-fn
|
||||||
"Create a predefined check function"
|
"Create a predefined check function"
|
||||||
[s & {:keys [hint type code]}]
|
[s & {:keys [hint type code]}]
|
||||||
(let [s (schema s)
|
(let [s #?(:clj
|
||||||
|
(schema s)
|
||||||
|
:cljs
|
||||||
|
(try
|
||||||
|
(schema s)
|
||||||
|
(catch :default cause
|
||||||
|
(let [data (ex-data cause)]
|
||||||
|
(if (= :malli.core/invalid-schema (:type data))
|
||||||
|
(throw (ex-info
|
||||||
|
(str "Invalid schema\n"
|
||||||
|
(pp/pprint-str (:data data)))
|
||||||
|
{}))
|
||||||
|
(throw cause))))))
|
||||||
|
|
||||||
validator* (delay (m/validator s))
|
validator* (delay (m/validator s))
|
||||||
explainer* (delay (m/explainer s))
|
explainer* (delay (m/explainer s))
|
||||||
hint (or ^boolean hint "check error")
|
hint (or ^boolean hint "check error")
|
||||||
|
|||||||
Reference in New Issue
Block a user