mirror of
https://github.com/penpot/penpot.git
synced 2025-07-11 16:57:16 +02:00
✨ Minor improvements on error reporting mechanism.
This commit is contained in:
parent
ef17af38a1
commit
ffdd539233
6 changed files with 59 additions and 45 deletions
|
@ -112,13 +112,16 @@
|
|||
|
||||
(render-template [report]
|
||||
(binding [ppr/*print-right-margin* 300]
|
||||
(let [context (dissoc report :trace :cause :params :data :spec-prob :spec-problems :error :explain)
|
||||
(let [context (dissoc report :trace :cause :params :data :spec-problems :spec-value :error :explain :hint :message)
|
||||
params {:context (with-out-str (ppr/pprint context))
|
||||
:data (:data report)
|
||||
:trace (or (:cause report)
|
||||
(:trace report)
|
||||
(some-> report :error :trace))
|
||||
:params (:params report)}]
|
||||
:hint (:hint report)
|
||||
:spec-problems (:spec-problems report)
|
||||
:spec-value (:spec-value report)
|
||||
:data (:data report)
|
||||
:trace (or (:cause report)
|
||||
(:trace report)
|
||||
(some-> report :error :trace))
|
||||
:params (:params report)}]
|
||||
(-> (io/resource "error-report.tmpl")
|
||||
(tmpl/render params)))))
|
||||
]
|
||||
|
|
|
@ -27,10 +27,11 @@
|
|||
{:id (uuid/next)
|
||||
:path (:uri request)
|
||||
:method (:request-method request)
|
||||
:hint (or (:hint data) (ex-message error))
|
||||
:params (l/stringify-data (:params request))
|
||||
:hint (ex-message error)
|
||||
:params (:params request)
|
||||
:spec-problems (some-> data ::s/problems)
|
||||
:data (some-> data (dissoc ::s/problems))
|
||||
:spec-value (some-> data ::s/value)
|
||||
:data (some-> data (dissoc ::s/problems ::s/value :hint))
|
||||
:ip-addr (parse-client-ip request)
|
||||
:profile-id (:profile-id request)}
|
||||
|
||||
|
@ -55,17 +56,17 @@
|
|||
(defmethod handle-exception :validation
|
||||
[err _]
|
||||
(let [edata (ex-data err)]
|
||||
{:status 400 :body (dissoc edata ::s/problems)}))
|
||||
{:status 400 :body (dissoc edata ::s/problems ::s/value)}))
|
||||
|
||||
(defmethod handle-exception :assertion
|
||||
[error request]
|
||||
(let [edata (ex-data error)]
|
||||
(l/with-context (get-error-context request error)
|
||||
(l/error :hint (ex-message error) :cause error))
|
||||
(l/error ::l/raw (ex-message error) :cause error))
|
||||
{:status 500
|
||||
:body {:type :server-error
|
||||
:code :assertion
|
||||
:data (dissoc edata ::s/problems)}}))
|
||||
:data (dissoc edata ::s/problems ::s/value)}}))
|
||||
|
||||
(defmethod handle-exception :not-found
|
||||
[err _]
|
||||
|
@ -84,7 +85,7 @@
|
|||
(handle-exception (:handling edata) request)
|
||||
(do
|
||||
(l/with-context (get-error-context request error)
|
||||
(l/error :hint (ex-message error) :cause error))
|
||||
(l/error ::l/raw (ex-message error) :cause error))
|
||||
|
||||
{:status 500
|
||||
:body {:type :server-error
|
||||
|
@ -97,10 +98,7 @@
|
|||
(let [state (.getSQLState ^java.sql.SQLException error)]
|
||||
|
||||
(l/with-context (get-error-context request error)
|
||||
(l/error :hint "psql exception"
|
||||
:error-message (ex-message error)
|
||||
:state state
|
||||
:cause error))
|
||||
(l/error ::l/raw (ex-message error) :cause error))
|
||||
|
||||
(cond
|
||||
(= state "57014")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue