From 9c73444102ff8870d79c4037bb9fad7d51cf00e8 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 21 Dec 2020 13:48:38 +0100 Subject: [PATCH] :bug: Minor fix on error reporting. --- backend/src/app/http/errors.clj | 26 +++++++++++++++----------- frontend/src/app/main/repo.cljs | 8 +++++--- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/backend/src/app/http/errors.clj b/backend/src/app/http/errors.clj index a57265ba5..19693b184 100644 --- a/backend/src/app/http/errors.clj +++ b/backend/src/app/http/errors.clj @@ -17,14 +17,15 @@ (defn get-context-string - [err request] - (str - "=| uri: " (pr-str (:uri request)) "\n" - "=| method: " (pr-str (:request-method request)) "\n" - "=| params: " (pr-str (:params request)) "\n" - (when (ex/ex-info? err) - (str "=| ex-data: " (pr-str (ex-data err)) "\n")) - "\n")) + [request edata] + (str "=| uri: " (pr-str (:uri request)) "\n" + "=| method: " (pr-str (:request-method request)) "\n" + "=| params: " (pr-str (:params request)) "\n" + + (when (map? edata) + (str "=| ex-data: " (pr-str edata) "\n")) + + "\n")) (defmulti handle-exception (fn [err & _rest] @@ -84,9 +85,12 @@ (log/errorf error (str "Internal Error\n" (get-context-string request edata))) - - {:status 500 - :body (dissoc edata :data)})) + (if (nil? edata) + {:status 500 + :body {:type :server-error + :hint (ex-message error)}} + {:status 500 + :body (dissoc edata :data)}))) (defn handle [error req] diff --git a/frontend/src/app/main/repo.cljs b/frontend/src/app/main/repo.cljs index c6d1370e8..42f7e4a14 100644 --- a/frontend/src/app/main/repo.cljs +++ b/frontend/src/app/main/repo.cljs @@ -38,9 +38,11 @@ (rx/throw {:type :offline}) :else - (rx/throw {:type :server-error - :status (:status response) - :body (:body response)}))) + (rx/throw (merge {:type :server-error + :status (:status response)} + (:body response))))) + + (defn send-query! [id params]