mirror of
https://github.com/penpot/penpot.git
synced 2025-02-14 11:09:04 -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
|
(defmethod handle-exception :validation
|
||||||
[err req]
|
[err req]
|
||||||
(let [header (get-in req [:headers "accept"])
|
(let [header (get-in req [:headers "accept"])
|
||||||
edata (ex-data err)]
|
error (ex-data err)]
|
||||||
(cond
|
(cond
|
||||||
(and (str/starts-with? header "text/html")
|
(and (str/starts-with? header "text/html")
|
||||||
(= :spec-validation (:code edata)))
|
(= :spec-validation (:code error)))
|
||||||
{:status 400
|
{:status 400
|
||||||
:headers {"content-type" "text/html"}
|
:headers {"content-type" "text/html"}
|
||||||
:body (str "<pre style='font-size:16px'>"
|
:body (str "<pre style='font-size:16px'>"
|
||||||
(with-out-str
|
(:hint-verbose error)
|
||||||
(:data edata))
|
|
||||||
"</pre>\n")}
|
"</pre>\n")}
|
||||||
:else
|
:else
|
||||||
{:status 400
|
{:status 400
|
||||||
:body edata})))
|
:body error})))
|
||||||
|
|
||||||
(defmethod handle-exception :ratelimit
|
(defmethod handle-exception :ratelimit
|
||||||
[_ _]
|
[_ _]
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
(defstate semaphore
|
(defstate semaphore
|
||||||
:start (Semaphore. (:image-process-max-threads cfg/config 1)))
|
:start (Semaphore. (:image-process-max-threads cfg/config 1)))
|
||||||
|
|
||||||
|
|
||||||
;; --- Generic specs
|
;; --- Generic specs
|
||||||
|
|
||||||
(s/def :internal.http.upload/filename ::us/string)
|
(s/def :internal.http.upload/filename ::us/string)
|
||||||
|
|
|
@ -186,10 +186,16 @@
|
||||||
[spec data]
|
[spec data]
|
||||||
(let [result (s/conform spec data)]
|
(let [result (s/conform spec data)]
|
||||||
(when (= result ::s/invalid)
|
(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
|
(throw (ex/error :type :validation
|
||||||
:code :spec-validation
|
:code :spec-validation
|
||||||
:data data))))
|
:data data
|
||||||
|
:hint nhint
|
||||||
|
:hint-verbose vhint))))
|
||||||
result))
|
result))
|
||||||
|
|
||||||
(defmacro instrument!
|
(defmacro instrument!
|
||||||
|
|
|
@ -209,6 +209,18 @@
|
||||||
;; --- Error Handling
|
;; --- Error Handling
|
||||||
|
|
||||||
(defmethod ptk/handle-error :validation
|
(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]
|
[error]
|
||||||
(ts/schedule
|
(ts/schedule
|
||||||
(st/emitf (dm/show {:content "Unexpected validation error (server side)."
|
(st/emitf (dm/show {:content "Unexpected validation error (server side)."
|
||||||
|
|
Loading…
Add table
Reference in a new issue