mirror of
https://github.com/penpot/penpot.git
synced 2025-02-18 13:04:38 -05:00
✨ Minor improvements on http reporting on 400 responses
This commit is contained in:
parent
5576b7568c
commit
57666e9173
3 changed files with 17 additions and 4 deletions
|
@ -61,8 +61,15 @@
|
||||||
|
|
||||||
(defmethod handle-exception :validation
|
(defmethod handle-exception :validation
|
||||||
[err _]
|
[err _]
|
||||||
(let [edata (ex-data err)]
|
(let [data (ex-data err)
|
||||||
{:status 400 :body (dissoc edata ::s/problems ::s/value)}))
|
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
|
(defmethod handle-exception :assertion
|
||||||
[error request]
|
[error request]
|
||||||
|
|
|
@ -257,7 +257,7 @@
|
||||||
(let [data (s/explain-data spec data)]
|
(let [data (s/explain-data spec data)]
|
||||||
(throw (ex/error :type :validation
|
(throw (ex/error :type :validation
|
||||||
:code :spec-validation
|
:code :spec-validation
|
||||||
::s/problems (::s/problems data)))))
|
::ex/data data))))
|
||||||
result))
|
result))
|
||||||
|
|
||||||
(defmacro instrument!
|
(defmacro instrument!
|
||||||
|
|
|
@ -81,7 +81,13 @@
|
||||||
(js/console.group "Validation Error:")
|
(js/console.group "Validation Error:")
|
||||||
(ex/ignoring
|
(ex/ignoring
|
||||||
(js/console.info
|
(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:"))
|
(js/console.groupEnd "Validation Error:"))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue