Browse Source

fix(api): query method and error handling

logseq.app.q failing and error returned as blank `{}` on cmdline
Gabriel Horner 4 months ago
parent
commit
98746156ed
2 changed files with 2 additions and 2 deletions
  1. 1 1
      src/main/electron/listener.cljs
  2. 1 1
      src/main/logseq/api.cljs

+ 1 - 1
src/main/electron/listener.cljs

@@ -141,7 +141,7 @@
                            (throw (js/Error. (str "MethodNotExist: " method))))
                          (-> (p/promise (apply js-invoke methodTarget method' args))
                              (p/then #(ret-fn! %))
-                             (p/catch #(ret-fn! {:error %}))))
+                             (p/catch #(ret-fn! {:error (.-message %)}))))
                        (catch js/Error e
                          (ret-fn! {:error (.-message e)}))))))
 

+ 1 - 1
src/main/logseq/api.cljs

@@ -1106,7 +1106,7 @@
     (p/let [result (query-dsl/query repo query-string
                                     {:disable-reactive? true
                                      :return-promise? true})]
-      (bean/->js (sdk-utils/normalize-keyword-for-json (flatten @result))))))
+      (bean/->js (sdk-utils/normalize-keyword-for-json (flatten result))))))
 
 (defn ^:export datascript_query
   [query & inputs]