فهرست منبع

Make changes based on Gabe's suggestions

Tienson Qin 3 سال پیش
والد
کامیت
df2f749c2c
2فایلهای تغییر یافته به همراه8 افزوده شده و 9 حذف شده
  1. 5 7
      src/main/frontend/handler/common.cljs
  2. 3 2
      src/main/frontend/handler/events.cljs

+ 5 - 7
src/main/frontend/handler/common.cljs

@@ -110,7 +110,7 @@
   [content error-message-or-handler]
   (try
     (reader/read-string content)
-    (catch js/Error e
+    (catch :default e
       (js/console.error e)
       (if (fn? error-message-or-handler)
         (error-message-or-handler e)
@@ -135,9 +135,8 @@
   [content]
   (try
    (reader/read-string content)
-   (catch js/Error e
-     (println "Parsing metadata file failed: ")
-     (js/console.dir e)
+   (catch :default e
+     (log/error :parse/metadata-failed e)
      {})))
 
 (defn request-app-tokens!
@@ -239,8 +238,7 @@
   [content]
   (try
     (rewrite/parse-string content)
-    (catch js/Error e
-      (println "Parsing config file failed: ")
-      (js/console.error e)
+    (catch :default e
+      (log/error :parse/config-failed e)
       (state/pub-event! [:backup/broken-config (state/get-current-repo) content])
       (rewrite/parse-string config/config-default-content))))

+ 3 - 2
src/main/frontend/handler/events.cljs

@@ -35,7 +35,8 @@
             [frontend.mobile.util :as mobile-util]
             [frontend.encrypt :as encrypt]
             [promesa.core :as p]
-            [frontend.fs :as fs]))
+            [frontend.fs :as fs]
+            [clojure.string :as string]))
 
 ;; TODO: should we move all events here?
 
@@ -293,7 +294,7 @@
 (defmethod handle :backup/broken-config [[_ repo content]]
   (when (and repo content)
     (let [path (config/get-config-path)
-          broken-path (str path "-broken")]
+          broken-path (string/replace path "/config.edn" "/broken-config.edn")]
       (p/let [_ (fs/write-file! repo (config/get-repo-dir repo) broken-path content {})
               _ (file-handler/alter-file repo path config/config-default-content {:skip-compare? true})]
         (notification/show!