Browse Source

enhance(rtc): err handling improvements (3)

rcmerci 2 months ago
parent
commit
6cc59819b5

+ 4 - 4
src/main/frontend/handler/db_based/rtc.cljs

@@ -62,8 +62,8 @@
   (p/let [_ (js/Promise. user-handler/task--ensure-id&access-token)
           token (state/get-auth-id-token)
           start-ex (state/<invoke-db-worker :thread-api/rtc-async-branch-graph repo token)]
-    (when-let [ex-data* (:ex-data start-ex)]
-      (throw (ex-info (:ex-message start-ex) ex-data*)))))
+    (when (instance? ExceptionInfo start-ex)
+      (throw start-ex))))
 
 (defn notification-download-higher-schema-graph!
   [graph-name graph-uuid schema-version]
@@ -113,7 +113,7 @@
              _ (case (:type ex-data*)
                  (:rtc.exception/not-rtc-graph
                   :rtc.exception/not-found-db-conn)
-                 (notification/show! (:ex-message start-ex) :error)
+                 (notification/show! (ex-message start-ex) :error)
 
                  :rtc.exception/major-schema-version-mismatched
                  (case (:sub-type ex-data*)
@@ -124,7 +124,7 @@
                    ;; else
                    (do (log/info :start-ex start-ex)
                        (notification/show! [:div
-                                            [:div (:ex-message start-ex)]
+                                            [:div (ex-message start-ex)]
                                             [:div (-> ex-data*
                                                       (select-keys [:app :local :remote])
                                                       pp/pprint

+ 2 - 2
src/main/frontend/worker/rtc/core.cljs

@@ -527,7 +527,7 @@
           (ex-info "Not found db-conn" {:type :rtc.exception/not-found-db-conn :repo repo}))]
     (m/sp
       (if (instance? ExceptionInfo r)
-        (r.ex/->map r)
+        r
         (let [major-schema-version (db-schema/major-version schema-version)
               {:keys [get-ws-create-task]} (gen-get-ws-create-map--memoized (ws-util/get-ws-url token))]
           (m/? (r.upload-download/new-task--upload-graph
@@ -545,7 +545,7 @@
           (ex-info "Not found db-conn" {:type :rtc.exception/not-found-db-conn :repo repo}))]
     (m/sp
       (if (instance? ExceptionInfo r)
-        (r.ex/->map r)
+        r
         (let [major-schema-version (db-schema/major-version schema-version)
               {:keys [get-ws-create-task]} (gen-get-ws-create-map--memoized (ws-util/get-ws-url token))]
           (m/? (r.upload-download/new-task--branch-graph

+ 0 - 9
src/main/frontend/worker/rtc/exception.cljs

@@ -52,15 +52,6 @@ the server will put it to s3 and return its presigned-url to clients."}
 (def ex-unknown-server-error
   (ex-info "Unknown server error" {:type :rtc.exception/unknown-server-error}))
 
-(defn ->map
-  "TODO: deprecated
-  This function was used to map exceptions to a format suitable for posting messages to the UI thread.
-  However, ldb/write-transit-str now supports the ExceptionInfo type, making this function unnecessary."
-  [e]
-  (when-let [data (ex-data e)]
-    {:ex-data data
-     :ex-message (ex-message e)}))
-
 (defn e->ex-info
   [e]
   (cond