CONTEXT:
+
+
+
+
{{hint}}
+{{context}}
-
{% endif %}
-
{% if data %}
PARAMS:
+ REQUEST PARAMS:
{{params}}
ERROR DATA:
@@ -139,6 +145,15 @@
+
+ {% endif %}
+
{% if trace %}
SPEC VALUE:
+
+
+ {{spec-value}}+
TRACE:
diff --git a/backend/src/app/http/debug.clj b/backend/src/app/http/debug.clj
index 8a3aef42d..7d12829b0 100644
--- a/backend/src/app/http/debug.clj
+++ b/backend/src/app/http/debug.clj
@@ -112,13 +112,16 @@
(render-template [report]
(binding [ppr/*print-right-margin* 300]
- (let [context (dissoc report :trace :cause :params :data :spec-prob :spec-problems :error :explain)
+ (let [context (dissoc report :trace :cause :params :data :spec-problems :spec-value :error :explain :hint :message)
params {:context (with-out-str (ppr/pprint context))
- :data (:data report)
- :trace (or (:cause report)
- (:trace report)
- (some-> report :error :trace))
- :params (:params report)}]
+ :hint (:hint report)
+ :spec-problems (:spec-problems report)
+ :spec-value (:spec-value report)
+ :data (:data report)
+ :trace (or (:cause report)
+ (:trace report)
+ (some-> report :error :trace))
+ :params (:params report)}]
(-> (io/resource "error-report.tmpl")
(tmpl/render params)))))
]
diff --git a/backend/src/app/http/errors.clj b/backend/src/app/http/errors.clj
index 99992a967..b7424403f 100644
--- a/backend/src/app/http/errors.clj
+++ b/backend/src/app/http/errors.clj
@@ -27,10 +27,11 @@
{:id (uuid/next)
:path (:uri request)
:method (:request-method request)
- :hint (or (:hint data) (ex-message error))
- :params (l/stringify-data (:params request))
+ :hint (ex-message error)
+ :params (:params request)
:spec-problems (some-> data ::s/problems)
- :data (some-> data (dissoc ::s/problems))
+ :spec-value (some-> data ::s/value)
+ :data (some-> data (dissoc ::s/problems ::s/value :hint))
:ip-addr (parse-client-ip request)
:profile-id (:profile-id request)}
@@ -55,17 +56,17 @@
(defmethod handle-exception :validation
[err _]
(let [edata (ex-data err)]
- {:status 400 :body (dissoc edata ::s/problems)}))
+ {:status 400 :body (dissoc edata ::s/problems ::s/value)}))
(defmethod handle-exception :assertion
[error request]
(let [edata (ex-data error)]
(l/with-context (get-error-context request error)
- (l/error :hint (ex-message error) :cause error))
+ (l/error ::l/raw (ex-message error) :cause error))
{:status 500
:body {:type :server-error
:code :assertion
- :data (dissoc edata ::s/problems)}}))
+ :data (dissoc edata ::s/problems ::s/value)}}))
(defmethod handle-exception :not-found
[err _]
@@ -84,7 +85,7 @@
(handle-exception (:handling edata) request)
(do
(l/with-context (get-error-context request error)
- (l/error :hint (ex-message error) :cause error))
+ (l/error ::l/raw (ex-message error) :cause error))
{:status 500
:body {:type :server-error
@@ -97,10 +98,7 @@
(let [state (.getSQLState ^java.sql.SQLException error)]
(l/with-context (get-error-context request error)
- (l/error :hint "psql exception"
- :error-message (ex-message error)
- :state state
- :cause error))
+ (l/error ::l/raw (ex-message error) :cause error))
(cond
(= state "57014")
diff --git a/common/src/app/common/exceptions.cljc b/common/src/app/common/exceptions.cljc
index 0bfbc8988..dbc63a8ba 100644
--- a/common/src/app/common/exceptions.cljc
+++ b/common/src/app/common/exceptions.cljc
@@ -12,26 +12,23 @@
(s/def ::type keyword?)
(s/def ::code keyword?)
-(s/def ::message string?)
(s/def ::hint string?)
(s/def ::cause #?(:clj #(instance? Throwable %)
:cljs #(instance? js/Error %)))
+
(s/def ::error-params
(s/keys :req-un [::type]
:opt-un [::code
::hint
- ::message
::cause]))
(defn error
- [& {:keys [message hint cause] :as params}]
+ [& {:keys [hint cause ::data] :as params}]
(s/assert ::error-params params)
- (let [message (or message hint "")
- payload (-> params
- (dissoc :cause)
- (dissoc :message)
- (assoc :hint message))]
- (ex-info message payload cause)))
+ (let [payload (-> params
+ (dissoc :cause ::data)
+ (merge data))]
+ (ex-info hint payload cause)))
(defmacro raise
[& args]
diff --git a/common/src/app/common/logging.cljc b/common/src/app/common/logging.cljc
index b9940f1ea..e6087b2ed 100644
--- a/common/src/app/common/logging.cljc
+++ b/common/src/app/common/logging.cljc
@@ -175,14 +175,15 @@
level-sym (gensym "log")]
`(let [~logger-sym (get-logger ~logger)
~level-sym (get-level ~level)]
- (if (enabled? ~logger-sym ~level-sym)
+ (when (enabled? ~logger-sym ~level-sym)
~(if async
- `(let [cdata# (ThreadContext/getImmutableContext)]
- (send-off logging-agent
- (fn [_#]
- (with-context (into {:cause ~cause} cdata#)
- (->> (or ~raw (build-map-message ~props))
- (write-log! ~logger-sym ~level-sym ~cause))))))
+ `(->> (ThreadContext/getImmutableContext)
+ (send-off logging-agent
+ (fn [_# cdata#]
+ (with-context (into {:cause ~cause} cdata#)
+ (->> (or ~raw (build-map-message ~props))
+ (write-log! ~logger-sym ~level-sym ~cause))))))
+
`(let [message# (or ~raw (build-map-message ~props))]
(write-log! ~logger-sym ~level-sym ~cause message#))))))))
diff --git a/common/src/app/common/spec.cljc b/common/src/app/common/spec.cljc
index d568d2d9f..275ddfb2e 100644
--- a/common/src/app/common/spec.cljc
+++ b/common/src/app/common/spec.cljc
@@ -217,8 +217,8 @@
(ex/raise :type :assertion
:code :spec-validation
:hint hint
- :ctx ctx
- :value val
+ ::ex/data ctx
+ ::s/value val
::s/problems (::s/problems data)))))