0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-09 16:48:16 -05:00

Minor improvements on http reporting on 400 responses

This commit is contained in:
Andrey Antukh 2022-02-01 13:53:10 +01:00
parent 5576b7568c
commit 57666e9173
3 changed files with 17 additions and 4 deletions

View file

@ -61,8 +61,15 @@
(defmethod handle-exception :validation
[err _]
(let [edata (ex-data err)]
{:status 400 :body (dissoc edata ::s/problems ::s/value)}))
(let [data (ex-data err)
explain (binding [s/*explain-out* expound/printer]
(with-out-str
(s/explain-out (update data ::s/problems #(take 10 %)))))]
{:status 400
:body (-> data
(dissoc ::s/problems)
(dissoc ::s/value)
(assoc :explain explain))}))
(defmethod handle-exception :assertion
[error request]

View file

@ -257,7 +257,7 @@
(let [data (s/explain-data spec data)]
(throw (ex/error :type :validation
:code :spec-validation
::s/problems (::s/problems data)))))
::ex/data data))))
result))
(defmacro instrument!

View file

@ -81,7 +81,13 @@
(js/console.group "Validation Error:")
(ex/ignoring
(js/console.info
(with-out-str (pprint error))))
(with-out-str (pprint (dissoc error :explain)))))
(when-let [explain (:explain error)]
(js/console.group "Spec explain:")
(js/console.log explain)
(js/console.groupEnd "Spec explain:"))
(js/console.groupEnd "Validation Error:"))