From 59ba87d9cd8fe7d6788a44ce11388dedff7b2f3a Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 8 Nov 2022 11:26:58 +0100 Subject: [PATCH] :sparkles: Properly report malformed json error --- backend/src/app/http/middleware.clj | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/src/app/http/middleware.clj b/backend/src/app/http/middleware.clj index 9ccdd8370..ce0471aff 100644 --- a/backend/src/app/http/middleware.clj +++ b/backend/src/app/http/middleware.clj @@ -19,6 +19,7 @@ [yetti.request :as yrq] [yetti.response :as yrs]) (:import + com.fasterxml.jackson.core.JsonParseException com.fasterxml.jackson.core.io.JsonEOFException io.undertow.server.RequestTooBigException java.io.OutputStream)) @@ -60,10 +61,13 @@ :code :request-body-too-large :hint (ex-message cause))) - (instance? JsonEOFException cause) + + (or (instance? JsonEOFException cause) + (instance? JsonParseException cause)) (raise (ex/error :type :validation :code :malformed-json - :hint (ex-message cause))) + :hint (ex-message cause) + :cause cause)) :else (raise cause)))]