From 072e30674f07009a500737fa77dab245d94df47d Mon Sep 17 00:00:00 2001 From: William Boman Date: Mon, 26 Dec 2022 16:30:28 +0100 Subject: refactor(async): error with stack level 0 (#801) --- lua/mason-core/async/init.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lua') 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(...) -- cgit v1.2.3-70-g09d2