0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-03 12:59:12 -05:00

🐛 Fix issue on 400 error handler.

This commit is contained in:
Andrey Antukh 2022-02-02 15:31:54 +01:00
parent e9f45a0d0a
commit 7710ffcbf1

View file

@ -59,17 +59,25 @@
[err _] [err _]
{:status 400 :body (ex-data err)}) {:status 400 :body (ex-data err)})
(defn- explain-spec-error-data
[data]
(when (and (::s/problems data)
(::s/value data)
(::s/spec data))
(binding [s/*explain-out* expound/printer]
(with-out-str
(s/explain-out (update data ::s/problems #(take 10 %)))))))
(defmethod handle-exception :validation (defmethod handle-exception :validation
[err _] [err _]
(let [data (ex-data err) (let [data (ex-data err)
explain (binding [s/*explain-out* expound/printer] explain (explain-spec-error-data data)]
(with-out-str
(s/explain-out (update data ::s/problems #(take 10 %)))))]
{:status 400 {:status 400
:body (-> data :body (-> data
(dissoc ::s/problems) (dissoc ::s/problems)
(dissoc ::s/value) (dissoc ::s/value)
(assoc :explain explain))})) (cond-> explain (assoc :explain explain)))}))
(defmethod handle-exception :assertion (defmethod handle-exception :assertion
[error request] [error request]