diff --git a/backend/src/app/loggers/database.clj b/backend/src/app/loggers/database.clj index 196845a967..d15d5704f1 100644 --- a/backend/src/app/loggers/database.clj +++ b/backend/src/app/loggers/database.clj @@ -41,7 +41,7 @@ (if (or (instance? java.util.concurrent.CompletionException cause) (instance? java.util.concurrent.ExecutionException cause)) (-> record - (assoc ::trace (ex/format-throwable cause :data? false :explain? false :header? false :summary? false)) + (assoc ::trace (ex/format-throwable cause :data? true :explain? false :header? false :summary? false)) (assoc ::l/cause (ex-cause cause)) (record->report)) @@ -64,18 +64,18 @@ message)) @message) :trace (or (::trace record) - (some-> cause (ex/format-throwable :data? false :explain? false :header? false :summary? false)))} + (some-> cause (ex/format-throwable :data? true :explain? false :header? false :summary? false)))} (when-let [params (or (:request/params context) (:params context))] - {:params (pp/pprint-str params :length 30 :level 13)}) + {:params (pp/pprint-str params :length 20 :level 15)}) (when-let [value (:value context)] - {:value (pp/pprint-str value :length 30 :level 12)}) + {:value (pp/pprint-str value :length 30 :level 13)}) (when-let [data (some-> data (dissoc ::s/problems ::s/value ::s/spec ::sm/explain :hint))] - {:data (pp/pprint-str data :length 30 :level 12)}) + {:data (pp/pprint-str data :length 30 :level 13)}) - (when-let [explain (ex/explain data :length 30 :level 12)] + (when-let [explain (ex/explain data :length 30 :level 13)] {:explain explain}))))) (defn error-record? diff --git a/backend/src/app/rpc/commands/files.clj b/backend/src/app/rpc/commands/files.clj index 83140780fd..16a53e8b5b 100644 --- a/backend/src/app/rpc/commands/files.clj +++ b/backend/src/app/rpc/commands/files.clj @@ -559,6 +559,8 @@ f.project_id, f.created_at, f.modified_at, + f.data_backend, + f.data_ref_id, f.name, f.version, f.is_shared, diff --git a/common/src/app/common/exceptions.cljc b/common/src/app/common/exceptions.cljc index 5cceeb7222..4bb36461ea 100644 --- a/common/src/app/common/exceptions.cljc +++ b/common/src/app/common/exceptions.cljc @@ -47,10 +47,26 @@ `(try ~@exprs (catch Throwable e# nil)))) (defmacro try! - [& exprs] - (if (:ns &env) - `(try ~@exprs (catch :default e# e#)) - `(try ~@exprs (catch Throwable e# e#)))) + [expr & {:keys [reraise-with on-exception]}] + (let [ex-sym + (gensym "exc") + + generate-catch + (fn [] + (cond + (map? reraise-with) + `(ex/raise ~@(mapcat identity reraise-with) :cause ~ex-sym) + + on-exception + `(let [handler# ~on-exception] + (handler# ~ex-sym)) + + :else + ex-sym))] + + (if (:ns &env) + `(try ~expr (catch :default ~ex-sym ~(generate-catch))) + `(try ~expr (catch Throwable ~ex-sym ~(generate-catch)))))) (defn ex-info? [v] diff --git a/common/src/app/common/files/changes.cljc b/common/src/app/common/files/changes.cljc index 5dda3adb0f..c5d1812291 100644 --- a/common/src/app/common/files/changes.cljc +++ b/common/src/app/common/files/changes.cljc @@ -487,7 +487,9 @@ (cts/shape? shape-new)) (ex/raise :type :assertion :code :data-validation - :hint "invalid shape found after applying changes" + :hint (str "invalid shape found after applying changes on file " + (:id data-new)) + :file-id (:id data-new) ::sm/explain (cts/explain-shape shape-new))))))] (->> (into #{} (map :page-id) items) diff --git a/common/src/app/common/types/path.cljc b/common/src/app/common/types/path.cljc index eb0398787a..bcfa323c82 100644 --- a/common/src/app/common/types/path.cljc +++ b/common/src/app/common/types/path.cljc @@ -8,6 +8,7 @@ (:require [app.common.data :as d] [app.common.data.macros :as dm] + [app.common.exceptions :as ex] [app.common.files.helpers :as cpf] [app.common.geom.matrix :as gmt] [app.common.geom.point :as gpt] @@ -205,8 +206,18 @@ "Calculate the boolean content from shape and objects. Returns a packed PathData instance" [shape objects] - (-> (calc-bool-content* shape objects) - (impl/path-data))) + (ex/try! + (-> (calc-bool-content* shape objects) + (impl/path-data)) + + :on-exception + (fn [cause] + (ex/raise :type :internal + :code :invalid-path-content + :hint (str "unable to create bool content for shape " (:id shape)) + :content (str (:content shape)) + :shape-id (:id shape) + :cause cause)))) (defn update-bool-shape "Calculates the selrect+points for the boolean shape" diff --git a/common/src/app/common/types/path/bool.cljc b/common/src/app/common/types/path/bool.cljc index 9be2c5a792..af9be976b2 100644 --- a/common/src/app/common/types/path/bool.cljc +++ b/common/src/app/common/types/path/bool.cljc @@ -412,7 +412,7 @@ (defn calculate-content "Create a bool content from a collection of contents and specified - type." + type. Returns plain segments" [bool-type contents] ;; We apply the boolean operation in to each pair and the result to the next ;; element