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]