From 110fb2e8db7b9b88ab57f3e1130902e851e8cb2b Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 26 Jan 2022 14:18:44 +0100 Subject: [PATCH] :sparkles: Minor improvements on error reporting. Add missing expound. --- backend/resources/templates/error-report.tmpl | 18 +++++++++++++++--- backend/src/app/http/debug.clj | 6 +++--- backend/src/app/http/errors.clj | 3 +++ common/src/app/common/logging.cljc | 2 +- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/backend/resources/templates/error-report.tmpl b/backend/resources/templates/error-report.tmpl index bf97488623..a3fcc158d0 100644 --- a/backend/resources/templates/error-report.tmpl +++ b/backend/resources/templates/error-report.tmpl @@ -9,6 +9,12 @@ penpot - error report {{id}}
[]
[context]
[request params]
+ {% if data %} +
[error data]
+ {% endif %} + {% if spec-explain %} +
[spec explain]
+ {% endif %} {% if spec-problems %}
[spec problems]
{% endif %} @@ -16,9 +22,6 @@ penpot - error report {{id}}
[spec value]
{% endif %} - {% if data %} -
[error data]
- {% endif %} {% if trace %}
[error trace]
{% endif %} @@ -55,6 +58,15 @@ penpot - error report {{id}} {% endif %} + {% if spec-explain %} +
+
SPEC EXPLAIN:
+
+
{{spec-explain}}
+
+
+ {% endif %} + {% if spec-problems %}
SPEC PROBLEMS:
diff --git a/backend/src/app/http/debug.clj b/backend/src/app/http/debug.clj index 39e5973439..2098cd084f 100644 --- a/backend/src/app/http/debug.clj +++ b/backend/src/app/http/debug.clj @@ -150,14 +150,14 @@ (binding [ppr/*print-right-margin* 300] (let [context (dissoc report :trace :cause :params :data :spec-problems - :spec-value :error :explain :hint) + :spec-explain :spec-value :error :explain :hint) params {:context (with-out-str (ppr/pprint context)) :hint (:hint report) + :spec-explain (:spec-explain report) :spec-problems (:spec-problems report) :spec-value (:spec-value report) :data (:data report) - :trace (or (:cause report) - (:trace report) + :trace (or (:trace report) (some-> report :error :trace)) :params (:params report)}] (-> (io/resource "templates/error-report.tmpl") diff --git a/backend/src/app/http/errors.clj b/backend/src/app/http/errors.clj index 216fe91275..e8686d87c6 100644 --- a/backend/src/app/http/errors.clj +++ b/backend/src/app/http/errors.clj @@ -12,6 +12,7 @@ [app.common.uuid :as uuid] [clojure.pprint] [clojure.spec.alpha :as s] + [expound.alpha :as expound] [cuerdas.core :as str])) (defn- parse-client-ip @@ -31,6 +32,8 @@ :params (:params request) :spec-problems (some-> data ::s/problems) :spec-value (some-> data ::s/value) + :spec-explain (with-out-str + (expound/printer data)) :data (some-> data (dissoc ::s/problems ::s/value :hint)) :ip-addr (parse-client-ip request) :profile-id (:profile-id request)} diff --git a/common/src/app/common/logging.cljc b/common/src/app/common/logging.cljc index 6800253c38..aea40b9356 100644 --- a/common/src/app/common/logging.cljc +++ b/common/src/app/common/logging.cljc @@ -180,7 +180,7 @@ `(->> (ThreadContext/getImmutableContext) (send-off logging-agent (fn [_# cdata#] - (with-context (into {:cause ~cause} cdata#) + (with-context (into {} cdata#) (->> (or ~raw (build-map-message ~props)) (write-log! ~logger-sym ~level-sym ~cause))))))