From 1d174a4379f71ba4542cc0a78734c4bebfd9ba46 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 17 Jan 2022 17:48:42 +0100 Subject: [PATCH] :bug: Fix unexpected exception on time equiv impl. --- common/src/app/common/spec.cljc | 6 +----- frontend/src/app/main/errors.cljs | 15 ++++++--------- frontend/src/app/util/time.cljs | 8 ++++++-- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/common/src/app/common/spec.cljc b/common/src/app/common/spec.cljc index 275ddfb2ea..61688c426e 100644 --- a/common/src/app/common/spec.cljc +++ b/common/src/app/common/spec.cljc @@ -217,11 +217,7 @@ (ex/raise :type :assertion :code :spec-validation :hint hint - ::ex/data ctx - ::s/value val - ::s/problems (::s/problems data))))) - - + ::ex/data (merge ctx data))))) (defmacro assert "Development only assertion macro." diff --git a/frontend/src/app/main/errors.cljs b/frontend/src/app/main/errors.cljs index 45f46de0fc..194ff90c1f 100644 --- a/frontend/src/app/main/errors.cljs +++ b/frontend/src/app/main/errors.cljs @@ -106,14 +106,14 @@ ;; assertion (assertion that is preserved on production builds). From ;; the user perspective this should be treated as internal error. (defmethod ptk/handle-error :assertion - [{:keys [data stack message hint context] :as error}] + [{:keys [message hint] :as error}] (let [message (or message hint) message (str "Internal Assertion Error: " message) context (str/fmt "ns: '%s'\nname: '%s'\nfile: '%s:%s'" - (:ns context) - (:name context) - (str cf/public-uri "js/cljs-runtime/" (:file context)) - (:line context))] + (:ns error) + (:name error) + (str cf/public-uri "js/cljs-runtime/" (:file error)) + (:line error))] (ts/schedule (st/emitf (dm/show {:content "Internal error: assertion." @@ -123,10 +123,7 @@ ;; Print to the console some debugging info (js/console.group message) (js/console.info context) - (js/console.groupCollapsed "Stack Trace") - (js/console.info stack) - (js/console.groupEnd "Stack Trace") - (js/console.error (with-out-str (expound/printer data))) + (js/console.error (with-out-str (expound/printer error))) (js/console.groupEnd message))) ;; This happens when the backed server fails to process the diff --git a/frontend/src/app/util/time.cljs b/frontend/src/app/util/time.cljs index 9004f90f26..5fd1ee0c44 100644 --- a/frontend/src/app/util/time.cljs +++ b/frontend/src/app/util/time.cljs @@ -106,11 +106,15 @@ (extend-protocol IEquiv DateTime (-equiv [it other] - (.equals it other)) + (if other + (.equals it other) + false)) Duration (-equiv [it other] - (.equals it other))) + (if other + (.equals it other) + false))) (extend-protocol Inst DateTime