Improve error report of invalid image

This commit is contained in:
Andrey Antukh 2023-08-08 11:13:00 +02:00
parent 2a0031d23c
commit 81facd58c9
2 changed files with 6 additions and 3 deletions

View file

@ -74,7 +74,7 @@
::yrs/headers headers}))
(defmethod handle-exception :validation
[err _]
[err request]
(let [{:keys [code] :as data} (ex-data err)]
(cond
(= code :spec-validation)
@ -95,6 +95,11 @@
(= code :request-body-too-large)
{::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
{::yrs/status 400 ::yrs/body data})))

View file

@ -9,7 +9,6 @@
(:require
[app.common.data :as d]
[app.common.exceptions :as ex]
[app.common.logging :as l]
[app.common.media :as cm]
[app.common.schema :as sm]
[app.common.schema.generators :as sg]
@ -227,7 +226,6 @@
(defmethod process-error org.im4java.core.InfoException
[error]
(l/error :hint "unexpected error on processing image" :cause error)
(ex/raise :type :validation
:code :invalid-image
:hint "invalid image"