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:
parent
e9f45a0d0a
commit
7710ffcbf1
1 changed files with 12 additions and 4 deletions
|
@ -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]
|
||||
|
|
Loading…
Add table
Reference in a new issue