fix: cleanup inconsistent and incorrect import error handling

Some notified errors didn't include error object. Import cli didn't fail
on failure and stack was reversed. Error notifications sometimes
included full error which makes errors unreadable in CLI and possibly
confusing for users. Also fixed missing classpath. Part of
LOG-3176
This commit is contained in:
Gabriel Horner
2024-06-28 10:20:59 -04:00
parent 92134dec71
commit 9ee09372aa
3 changed files with 28 additions and 20 deletions

View File

@@ -9,6 +9,7 @@
["fs" :as fs]
["fs/promises" :as fsp]
[nbb.core :as nbb]
[nbb.classpath :as cp]
[babashka.cli :as cli]
[logseq.graph-parser.exporter :as gp-exporter]
[logseq.common.graph :as common-graph]
@@ -47,11 +48,14 @@
(println (string/join
"\n"
(map
#(str (:file %) (when (:line %) (str ":" (:line %)))
" calls #'"
(str (get-in % [:sci.impl/f-meta :ns]) "/" (get-in % [:sci.impl/f-meta :name])))
stack)))
(println (.-stack (get-in m [:ex-data :error])))))
#(str (:file %)
(when (:line %) (str ":" (:line %)))
(when (:sci.impl/f-meta %)
(str " calls #'" (get-in % [:sci.impl/f-meta :ns]) "/" (get-in % [:sci.impl/f-meta :name]))))
(reverse stack))))
(println (some-> (get-in m [:ex-data :error]) .-stack)))
(when (= :error (:level m))
(js/process.exit 1)))
(def default-export-options
{;; common options
@@ -125,7 +129,7 @@
((juxt node-path/dirname node-path/basename) graph-dir'))
[(node-path/join (os/homedir) "logseq" "graphs") db-graph-dir])
file-graph' (resolve-path file-graph)
conn (outliner-cli/init-conn dir db-name)
conn (outliner-cli/init-conn dir db-name {:classpath (cp/get-classpath)})
directory? (.isDirectory (fs/statSync file-graph'))]
(p/do!
(if directory?