Skip to content

Commit ccac829

Browse files
authored
feat: add await_handle_ok handler (#37)
1 parent 89aaf0e commit ccac829

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lua/java-core/utils/async.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,16 @@ local await_handle_error = function(defer)
116116
return value
117117
end
118118

119+
local await_handle_ok = function(defer)
120+
local ok, value = co.yield(defer)
121+
122+
if not ok then
123+
error(value)
124+
end
125+
126+
return value
127+
end
128+
119129
local await_all = function(defer)
120130
assert(type(defer) == 'table', 'type error :: expected table')
121131
return co.yield(join(defer))
@@ -124,6 +134,7 @@ end
124134
return {
125135
sync = async,
126136
wait_handle_error = await_handle_error,
137+
wait_handle_ok = await_handle_ok,
127138
wait = await,
128139
wait_all = await_all,
129140
wrap = wrap,

0 commit comments

Comments
 (0)