🐛 Fix corrner case on error report validationt

This commit is contained in:
Andrey Antukh 2025-10-14 12:22:46 +02:00
parent 1b6a833166
commit 39bdf026ca
1 changed files with 11 additions and 15 deletions

View File

@ -80,7 +80,7 @@
[:file-id ::sm/uuid]
[:page-id {:optional true} [:maybe ::sm/uuid]]])
(def check-error!
(def check-error
(sm/check-fn schema:error))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -96,21 +96,17 @@
(defn- report-error
[code hint shape file page & {:as args}]
(let [error {:code code
:hint hint
:shape shape
:file-id (:id file)
:page-id (:id page)
:shape-id (:id shape)
:args args}]
(let [error (d/without-nils
{:code code
:hint hint
:shape shape
:file-id (:id file)
:page-id (:id page)
:shape-id (:id shape)
:args args})]
(dm/assert!
"expected a valid `*errors*` dynamic binding"
(some? *errors*))
(dm/assert!
"expected valid error"
(check-error! error))
(assert (some? *errors*) "expected a valid `*errors*` dynamic binding")
(assert (check-error error))
(vswap! *errors* conj error)))