mirror of
https://github.com/penpot/penpot.git
synced 2025-07-16 15:45:15 +02:00
✨ Improve error report on uploading invalid image to library.
This commit is contained in:
parent
8847047fd1
commit
4d19b87fff
2 changed files with 5 additions and 5 deletions
|
@ -66,8 +66,7 @@
|
||||||
|
|
||||||
(defmethod process-error :default
|
(defmethod process-error :default
|
||||||
[error]
|
[error]
|
||||||
(ex/raise :type :internal
|
(throw error))
|
||||||
:cause error))
|
|
||||||
|
|
||||||
(defn run
|
(defn run
|
||||||
[{:keys [rlimits] :as cfg} {:keys [rlimit] :or {rlimit :image} :as params}]
|
[{:keys [rlimits] :as cfg} {:keys [rlimit] :or {rlimit :image} :as params}]
|
||||||
|
@ -184,11 +183,10 @@
|
||||||
(us/assert ::input input)
|
(us/assert ::input input)
|
||||||
(let [{:keys [path mtype]} input]
|
(let [{:keys [path mtype]} input]
|
||||||
(if (= mtype "image/svg+xml")
|
(if (= mtype "image/svg+xml")
|
||||||
(let [data (svg/parse (slurp path))
|
(let [info (some-> path slurp svg/pre-process svg/parse get-basic-info-from-svg)]
|
||||||
info (get-basic-info-from-svg data)]
|
|
||||||
(when-not info
|
(when-not info
|
||||||
(ex/raise :type :validation
|
(ex/raise :type :validation
|
||||||
:code :unable-to-retrieve-dimensions
|
:code :invalid-svg-file
|
||||||
:hint "uploaded svg does not provides dimensions"))
|
:hint "uploaded svg does not provides dimensions"))
|
||||||
(assoc info :mtype mtype))
|
(assoc info :mtype mtype))
|
||||||
|
|
||||||
|
@ -211,6 +209,7 @@
|
||||||
[error]
|
[error]
|
||||||
(ex/raise :type :validation
|
(ex/raise :type :validation
|
||||||
:code :invalid-image
|
:code :invalid-image
|
||||||
|
:hint "invalid image"
|
||||||
:cause error))
|
:cause error))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
:message (ex-message e))
|
:message (ex-message e))
|
||||||
(ex/raise :type :validation
|
(ex/raise :type :validation
|
||||||
:code :invalid-svg-file
|
:code :invalid-svg-file
|
||||||
|
:hint "invalid svg file"
|
||||||
:cause e))))
|
:cause e))))
|
||||||
|
|
||||||
(declare pre-process)
|
(declare pre-process)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue