From 7c73e44ab8d43e2d501abcee31f1ff3be0df7d69 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 28 Oct 2024 14:16:34 +0100 Subject: [PATCH] :sparkles: Add minor improvement on error reporting on shape validation --- backend/src/app/loggers/database.clj | 2 +- common/src/app/common/files/changes.cljc | 3 ++- common/src/app/common/types/shape.cljc | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/src/app/loggers/database.clj b/backend/src/app/loggers/database.clj index e2892d13f..bf9e9e3f9 100644 --- a/backend/src/app/loggers/database.clj +++ b/backend/src/app/loggers/database.clj @@ -63,7 +63,7 @@ (ex/format-throwable cause :data? false :explain? false :header? false :summary? false))} (when-let [params (or (:request/params context) (:params context))] - {:params (pp/pprint-str params :length 30 :level 12)}) + {:params (pp/pprint-str params :length 30 :level 13)}) (when-let [value (:value context)] {:value (pp/pprint-str value :length 30 :level 12)}) diff --git a/common/src/app/common/files/changes.cljc b/common/src/app/common/files/changes.cljc index 33a273121..3c097b5d0 100644 --- a/common/src/app/common/files/changes.cljc +++ b/common/src/app/common/files/changes.cljc @@ -418,7 +418,8 @@ (cts/shape? shape-new)) (ex/raise :type :assertion :code :data-validation - :hint "invalid shape found after applying changes")))))] + :hint "invalid shape found after applying changes" + ::sm/explain (cts/explain-shape shape-new))))))] (->> (into #{} (map :page-id) items) (mapcat (fn [page-id] diff --git a/common/src/app/common/types/shape.cljc b/common/src/app/common/types/shape.cljc index 5dfa9a016..1fb69eb29 100644 --- a/common/src/app/common/types/shape.cljc +++ b/common/src/app/common/types/shape.cljc @@ -361,6 +361,9 @@ (def valid-shape? (sm/lazy-validator schema:shape)) +(def explain-shape + (sm/lazy-explainer schema:shape)) + (defn has-images? [{:keys [fills strokes]}] (or (some :fill-image fills)