0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-15 17:21:17 -05:00

🐛 Fix unexpected exception on upload invalid image.

This commit is contained in:
Andrey Antukh 2021-02-09 16:48:41 +01:00 committed by Andrés Moya
parent 76e43f339a
commit 9b875aba21
2 changed files with 11 additions and 3 deletions

View file

@ -175,7 +175,12 @@
(ex/raise :type :internal
:code :rlimit-not-configured
:hint ":image rlimit not configured"))
(rlm/execute rlimit (process params))))
(try
(rlm/execute rlimit (process params))
(catch org.im4java.core.InfoException e
(ex/raise :type :validation
:code :invalid-image
:cause e)))))
;; --- Utility functions

View file

@ -417,13 +417,16 @@
(defn- handle-upload-error [on-error stream]
(->> stream
(rx/catch
(fn on-error [error]
(fn on-error* [error]
(if (ex/ex-info? error)
(on-error (ex-data error))
(on-error* (ex-data error))
(cond
(= (:code error) :media-type-not-allowed)
(rx/of (dm/error (tr "errors.media-type-not-allowed")))
(= (:code error) :invalid-image)
(rx/of (dm/error (tr "errors.media-type-not-allowed")))
(= (:code error) :media-too-large)
(rx/of (dm/error (tr "errors.media-too-large")))