mirror of https://github.com/logseq/logseq
enhance: display a warning if config.edn is invalid
parent
b5e9fbb314
commit
f186ec9ab0
|
@ -16,7 +16,8 @@
|
|||
[goog.object :as gobj]
|
||||
["ignore" :as Ignore]
|
||||
[lambdaisland.glogi :as log]
|
||||
[promesa.core :as p]))
|
||||
[promesa.core :as p]
|
||||
[frontend.handler.notification :as notification]))
|
||||
|
||||
(defn get-ref
|
||||
[repo-url]
|
||||
|
@ -106,18 +107,31 @@
|
|||
(db/get-file repo-url (config/get-config-path)))
|
||||
|
||||
(defn safe-read-string
|
||||
[content error-message]
|
||||
[content error-message-or-handler]
|
||||
(try
|
||||
(reader/read-string content)
|
||||
(catch js/Error e
|
||||
(println error-message)
|
||||
(js/console.dir e)
|
||||
(js/console.error e)
|
||||
(if (fn? error-message-or-handler)
|
||||
(error-message-or-handler e)
|
||||
(println error-message-or-handler))
|
||||
{})))
|
||||
|
||||
(defn reset-config!
|
||||
[repo-url content]
|
||||
(when-let [content (or content (get-config repo-url))]
|
||||
(let [config (safe-read-string content "Parsing config file failed: ")]
|
||||
(let [config (safe-read-string content
|
||||
(fn [e]
|
||||
(notification/show!
|
||||
[:div {:style {:z-index 999}}
|
||||
[:h1
|
||||
(str "Invalid configuration, error: " (ex-message e))]
|
||||
[:p "You can send the file \"config.edn\" to "
|
||||
[:code
|
||||
"help@logseq.com"]
|
||||
[:span ", we'll repair and send it back to you."]]]
|
||||
:error
|
||||
false)))]
|
||||
(state/set-config! repo-url config)
|
||||
config)))
|
||||
|
||||
|
|
Loading…
Reference in New Issue