From 8ea82021f032cbd4c77d6312f7f5edb1ec6f744a Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 13 Feb 2024 18:17:43 +0100 Subject: [PATCH] :sparkles: Add better error report on importing truncated binfile --- backend/src/app/binfile/v1.clj | 7 +++++++ backend/src/app/http/sse.clj | 3 --- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/backend/src/app/binfile/v1.clj b/backend/src/app/binfile/v1.clj index 207b40ec9..8597254c7 100644 --- a/backend/src/app/binfile/v1.clj +++ b/backend/src/app/binfile/v1.clj @@ -40,6 +40,7 @@ [promesa.util :as pu] [yetti.adapter :as yt]) (:import + com.github.luben.zstd.ZstdIOException com.github.luben.zstd.ZstdInputStream com.github.luben.zstd.ZstdOutputStream java.io.DataInputStream @@ -756,6 +757,12 @@ (pu/with-open [input (io/input-stream input)] (read-import! (assoc cfg ::input input)))) + (catch ZstdIOException cause + (ex/raise :type :validation + :code :invalid-penpot-file + :hint "invalid penpot file received: probably truncated" + :cause cause)) + (catch Throwable cause (vreset! cs cause) (throw cause)) diff --git a/backend/src/app/http/sse.clj b/backend/src/app/http/sse.clj index ec80df72d..868801091 100644 --- a/backend/src/app/http/sse.clj +++ b/backend/src/app/http/sse.clj @@ -61,9 +61,6 @@ (let [result (handler)] (events/tap :end result)) (catch Throwable cause - (binding [l/*context* (errors/request->context request)] - (l/err :hint "unexpected error process streaming response" - :cause cause)) (events/tap :error (errors/handle' cause request))) (finally (sp/close! events/*channel*)