🐛 Minor fix on error reporting.

This commit is contained in:
Andrey Antukh 2020-12-21 13:48:38 +01:00 committed by Alonso Torres
parent c5f4ae2242
commit 9c73444102
2 changed files with 20 additions and 14 deletions

View file

@ -17,14 +17,15 @@
(defn get-context-string
[err request]
(str
"=| uri: " (pr-str (:uri request)) "\n"
"=| method: " (pr-str (:request-method request)) "\n"
"=| params: " (pr-str (:params request)) "\n"
(when (ex/ex-info? err)
(str "=| ex-data: " (pr-str (ex-data err)) "\n"))
"\n"))
[request edata]
(str "=| uri: " (pr-str (:uri request)) "\n"
"=| method: " (pr-str (:request-method request)) "\n"
"=| params: " (pr-str (:params request)) "\n"
(when (map? edata)
(str "=| ex-data: " (pr-str edata) "\n"))
"\n"))
(defmulti handle-exception
(fn [err & _rest]
@ -84,9 +85,12 @@
(log/errorf error
(str "Internal Error\n"
(get-context-string request edata)))
{:status 500
:body (dissoc edata :data)}))
(if (nil? edata)
{:status 500
:body {:type :server-error
:hint (ex-message error)}}
{:status 500
:body (dissoc edata :data)})))
(defn handle
[error req]