0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 15:39:50 -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 _]
{: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
[err _]
(let [data (ex-data err)
explain (binding [s/*explain-out* expound/printer]
(with-out-str
(s/explain-out (update data ::s/problems #(take 10 %)))))]
explain (explain-spec-error-data data)]
{:status 400
:body (-> data
(dissoc ::s/problems)
(dissoc ::s/value)
(assoc :explain explain))}))
(cond-> explain (assoc :explain explain)))}))
(defmethod handle-exception :assertion
[error request]