aboutsummaryrefslogtreecommitdiffstats
path: root/lua/mason-core/async/init.lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-12-26 16:30:28 +0100
committerGitHub <noreply@github.com>2022-12-26 16:30:28 +0100
commit072e30674f07009a500737fa77dab245d94df47d (patch)
tree558567ac176590acd21eac686b4c4b00eb92a967 /lua/mason-core/async/init.lua
parentchore: update generated code (#800) (diff)
downloadmason-072e30674f07009a500737fa77dab245d94df47d.tar
mason-072e30674f07009a500737fa77dab245d94df47d.tar.gz
mason-072e30674f07009a500737fa77dab245d94df47d.tar.bz2
mason-072e30674f07009a500737fa77dab245d94df47d.tar.lz
mason-072e30674f07009a500737fa77dab245d94df47d.tar.xz
mason-072e30674f07009a500737fa77dab245d94df47d.tar.zst
mason-072e30674f07009a500737fa77dab245d94df47d.zip
refactor(async): error with stack level 0 (#801)
Diffstat (limited to 'lua/mason-core/async/init.lua')
-rw-r--r--lua/mason-core/async/init.lua6
1 files changed, 4 insertions, 2 deletions
diff --git a/lua/mason-core/async/init.lua b/lua/mason-core/async/init.lua
index 05401ca2..3c88eef0 100644
--- a/lua/mason-core/async/init.lua
+++ b/lua/mason-core/async/init.lua
@@ -29,7 +29,7 @@ end
local function await(resolver)
local ok, value = co.yield(Promise.new(resolver))
if not ok then
- error(value[1], 2)
+ error(value[1], 0)
end
return unpack(value)
end
@@ -38,8 +38,10 @@ local function table_pack(...)
return { n = select("#", ...), ... }
end
----@param async_fn fun(...)
+---@generic T
+---@param async_fn T
---@param should_reject_err boolean? Whether the provided async_fn takes a callback with the signature `fun(err, result)`
+---@return T
local function promisify(async_fn, should_reject_err)
return function(...)
local args = table_pack(...)