mirror of
https://github.com/penpot/penpot.git
synced 2025-07-19 21:27:21 +02:00
✨ Report restriction errors to logger
This commit is contained in:
parent
36518e0e6e
commit
895450c9d5
2 changed files with 9 additions and 7 deletions
|
@ -55,13 +55,16 @@
|
||||||
::yres/body (ex-data err)})
|
::yres/body (ex-data err)})
|
||||||
|
|
||||||
(defmethod handle-error :restriction
|
(defmethod handle-error :restriction
|
||||||
[err _ _]
|
[err request _]
|
||||||
(let [{:keys [code] :as data} (ex-data err)]
|
(let [{:keys [code] :as data} (ex-data err)]
|
||||||
(if (= code :method-not-allowed)
|
(if (= code :method-not-allowed)
|
||||||
{::yres/status 405
|
{::yres/status 405
|
||||||
::yres/body data}
|
::yres/body data}
|
||||||
{::yres/status 400
|
|
||||||
::yres/body data})))
|
(binding [l/*context* (request->context request)]
|
||||||
|
(l/err :hint "restriction error" :data data)
|
||||||
|
{::yres/status 400
|
||||||
|
::yres/body data}))))
|
||||||
|
|
||||||
(defmethod handle-error :rate-limit
|
(defmethod handle-error :rate-limit
|
||||||
[err _ _]
|
[err _ _]
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
:props (pp/pprint-str props :length 50)
|
:props (pp/pprint-str props :length 50)
|
||||||
:hint (or (ex-message cause) @message)
|
:hint (or (ex-message cause) @message)
|
||||||
:trace (or (::trace record)
|
:trace (or (::trace record)
|
||||||
(ex/format-throwable cause :data? false :explain? false :header? false :summary? false))}
|
(some-> cause (ex/format-throwable :data? false :explain? false :header? false :summary? false)))}
|
||||||
|
|
||||||
(when-let [params (or (:request/params context) (:params context))]
|
(when-let [params (or (:request/params context) (:params context))]
|
||||||
{:params (pp/pprint-str params :length 30 :level 13)})
|
{:params (pp/pprint-str params :length 30 :level 13)})
|
||||||
|
@ -74,9 +74,8 @@
|
||||||
{:explain explain})))))
|
{:explain explain})))))
|
||||||
|
|
||||||
(defn error-record?
|
(defn error-record?
|
||||||
[{:keys [::l/level ::l/cause]}]
|
[{:keys [::l/level]}]
|
||||||
(and (= :error level)
|
(= :error level))
|
||||||
(ex/exception? cause)))
|
|
||||||
|
|
||||||
(defn- handle-event
|
(defn- handle-event
|
||||||
[{:keys [::db/pool]} {:keys [::l/id] :as record}]
|
[{:keys [::db/pool]} {:keys [::l/id] :as record}]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue