mirror of
https://github.com/penpot/penpot.git
synced 2025-02-10 17:18:21 -05:00
🐛 Fix incorrect erorr reporting.
This commit is contained in:
parent
8f37f74d29
commit
01edf49de0
4 changed files with 24 additions and 8 deletions
|
@ -29,19 +29,18 @@
|
|||
(defmethod handle-exception :validation
|
||||
[err req]
|
||||
(let [header (get-in req [:headers "accept"])
|
||||
edata (ex-data err)]
|
||||
error (ex-data err)]
|
||||
(cond
|
||||
(and (str/starts-with? header "text/html")
|
||||
(= :spec-validation (:code edata)))
|
||||
(= :spec-validation (:code error)))
|
||||
{:status 400
|
||||
:headers {"content-type" "text/html"}
|
||||
:body (str "<pre style='font-size:16px'>"
|
||||
(with-out-str
|
||||
(:data edata))
|
||||
(:hint-verbose error)
|
||||
"</pre>\n")}
|
||||
:else
|
||||
{:status 400
|
||||
:body edata})))
|
||||
:body error})))
|
||||
|
||||
(defmethod handle-exception :ratelimit
|
||||
[_ _]
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
(defstate semaphore
|
||||
:start (Semaphore. (:image-process-max-threads cfg/config 1)))
|
||||
|
||||
|
||||
;; --- Generic specs
|
||||
|
||||
(s/def :internal.http.upload/filename ::us/string)
|
||||
|
|
|
@ -186,10 +186,16 @@
|
|||
[spec data]
|
||||
(let [result (s/conform spec data)]
|
||||
(when (= result ::s/invalid)
|
||||
(let [edata (s/explain-data spec data)]
|
||||
(let [edata (s/explain-data spec data)
|
||||
nhint (with-out-str
|
||||
(s/explain-out edata))
|
||||
vhint (with-out-str
|
||||
(expound/printer edata))]
|
||||
(throw (ex/error :type :validation
|
||||
:code :spec-validation
|
||||
:data data))))
|
||||
:data data
|
||||
:hint nhint
|
||||
:hint-verbose vhint))))
|
||||
result))
|
||||
|
||||
(defmacro instrument!
|
||||
|
|
|
@ -209,6 +209,18 @@
|
|||
;; --- Error Handling
|
||||
|
||||
(defmethod ptk/handle-error :validation
|
||||
[error]
|
||||
(ts/schedule
|
||||
(st/emitf (dm/show {:content "Unexpected validation error (server side)."
|
||||
:type :error
|
||||
:timeout 5000})))
|
||||
(when-let [explain (:hint-verbose error)]
|
||||
(js/console.group "Server Error")
|
||||
(js/console.error (if (map? error) (pr-str error) error))
|
||||
(js/console.error explain)
|
||||
(js/console.endGroup "Server Error")))
|
||||
|
||||
(defmethod ptk/handle-error :spec-validation
|
||||
[error]
|
||||
(ts/schedule
|
||||
(st/emitf (dm/show {:content "Unexpected validation error (server side)."
|
||||
|
|
Loading…
Add table
Reference in a new issue