From a633ed3c9a2eeb0fca9b9309137143a2579e18ef Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 27 Jan 2022 15:17:44 +0100 Subject: [PATCH] :sparkles: More tweaks on the error reporter. --- backend/src/app/http/errors.clj | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/backend/src/app/http/errors.clj b/backend/src/app/http/errors.clj index 6efd0e796..803c72bee 100644 --- a/backend/src/app/http/errors.clj +++ b/backend/src/app/http/errors.clj @@ -33,16 +33,17 @@ :spec-problems (some->> data ::s/problems (take 10) seq vec) :spec-value (some->> data ::s/value) - :spec-explain (binding [s/*explain-out* expound/printer] - (with-out-str - (s/explain-out (update data ::s/problems #(take 10 %))))) - - :data (some-> data (dissoc ::s/problems ::s/value :hint)) + :data (some-> data (dissoc ::s/problems ::s/value ::s/spec)) :ip-addr (parse-client-ip request) :profile-id (:profile-id request)} (let [headers (:headers request)] {:user-agent (get headers "user-agent") - :frontend-version (get headers "x-frontend-version" "unknown")})))) + :frontend-version (get headers "x-frontend-version" "unknown")}) + + (when (and data (::s/problems data)) + {:spec-explain (binding [s/*explain-out* expound/printer] + (with-out-str + (s/explain-out (update data ::s/problems #(take 10 %)))))})))) (defmulti handle-exception (fn [err & _rest] @@ -71,7 +72,7 @@ {:status 500 :body {:type :server-error :code :assertion - :data (dissoc edata ::s/problems ::s/value)}})) + :data (dissoc edata ::s/problems ::s/value ::s/spec)}})) (defmethod handle-exception :not-found [err _]