mirror of
https://github.com/penpot/penpot.git
synced 2025-07-13 20:47:16 +02:00
✨ Improve error report of invalid image
This commit is contained in:
parent
2a0031d23c
commit
81facd58c9
2 changed files with 6 additions and 3 deletions
|
@ -74,7 +74,7 @@
|
||||||
::yrs/headers headers}))
|
::yrs/headers headers}))
|
||||||
|
|
||||||
(defmethod handle-exception :validation
|
(defmethod handle-exception :validation
|
||||||
[err _]
|
[err request]
|
||||||
(let [{:keys [code] :as data} (ex-data err)]
|
(let [{:keys [code] :as data} (ex-data err)]
|
||||||
(cond
|
(cond
|
||||||
(= code :spec-validation)
|
(= code :spec-validation)
|
||||||
|
@ -95,6 +95,11 @@
|
||||||
(= code :request-body-too-large)
|
(= code :request-body-too-large)
|
||||||
{::yrs/status 413 ::yrs/body data}
|
{::yrs/status 413 ::yrs/body data}
|
||||||
|
|
||||||
|
(= code :invalid-image)
|
||||||
|
(binding [l/*context* (request->context request)]
|
||||||
|
(l/error :hint "unexpected error on processing image" :cause err)
|
||||||
|
{::yrs/status 400 ::yrs/body data})
|
||||||
|
|
||||||
:else
|
:else
|
||||||
{::yrs/status 400 ::yrs/body data})))
|
{::yrs/status 400 ::yrs/body data})))
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.exceptions :as ex]
|
[app.common.exceptions :as ex]
|
||||||
[app.common.logging :as l]
|
|
||||||
[app.common.media :as cm]
|
[app.common.media :as cm]
|
||||||
[app.common.schema :as sm]
|
[app.common.schema :as sm]
|
||||||
[app.common.schema.generators :as sg]
|
[app.common.schema.generators :as sg]
|
||||||
|
@ -227,7 +226,6 @@
|
||||||
|
|
||||||
(defmethod process-error org.im4java.core.InfoException
|
(defmethod process-error org.im4java.core.InfoException
|
||||||
[error]
|
[error]
|
||||||
(l/error :hint "unexpected error on processing image" :cause error)
|
|
||||||
(ex/raise :type :validation
|
(ex/raise :type :validation
|
||||||
:code :invalid-image
|
:code :invalid-image
|
||||||
:hint "invalid image"
|
:hint "invalid image"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue