Skip to content

Commit

Permalink
Handle eval errors by reporting with vim.notify
Browse files Browse the repository at this point in the history
  • Loading branch information
julienvincent committed Jun 17, 2024
1 parent 11ae897 commit 237d588
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
5 changes: 3 additions & 2 deletions clojure/io/julienvincent/clojure_test/json.clj
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@

#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
(defn load-test-namespaces []
(doseq [namespace (api.query/get-test-namespaces)]
(require namespace)))
(with-json-out
(doseq [namespace (api.query/get-test-namespaces)]
(require namespace))))

#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
(defn run-test [test-sym]
Expand Down
2 changes: 2 additions & 0 deletions lua/clojure-test/api/tests.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ end, 3)
local M = {}

function M.load_tests()
vim.notify("Loading tests...", vim.log.levels.INFO)
eval.eval(eval.API.load_test_namespaces)
vim.notify("Test namespaces loaded!", vim.log.levels.INFO)
end

function M.get_all_tests()
Expand Down
10 changes: 8 additions & 2 deletions lua/clojure-test/backends/conjure.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ function M.eval(ns, code, opts)
context = ns,
code = code,
["passive?"] = true,
["on-result"] = function(result)
future.set(result)
cb = function(result)
if result.err then
vim.notify(result.err, vim.log.levels.ERROR)
future.set_error(result.err)
end
if result.value then
future.set(result.value)
end
end,
})
end)
Expand Down

0 comments on commit 237d588

Please sign in to comment.