Skip to content

Commit 3c1915b

Browse files
committed
query不再抛错
1 parent 9ad55d5 commit 3c1915b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

binding/lua_channel.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ namespace bee::lua_channel {
157157
auto name = lua::checkstrview(L, 1);
158158
channel::box c = g_channel.query(name);
159159
if (!c) {
160-
return luaL_error(L, "Can't query channel '%s'", name.data());
160+
return 0;
161161
}
162162
lua::newudata<channel::box>(L, c);
163163
return 1;

test/test_channel.lua

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ end
1111
local test_channel = lt.test "channel"
1212

1313
function test_channel:test_create()
14-
lt.assertErrorMsgEquals("Can't query channel 'test'", channel.query, "test")
14+
lt.assertIsNil(channel.query "test")
1515
channel.create "test"
1616
lt.assertIsUserdata(channel.query "test")
1717
lt.assertIsUserdata(channel.query "test")
@@ -22,11 +22,11 @@ function test_channel:test_create()
2222
end
2323

2424
function test_channel:test_reset_1()
25-
lt.assertErrorMsgEquals("Can't query channel 'test'", channel.query, "test")
25+
lt.assertIsNil(channel.query "test")
2626
channel.create "test"
2727
lt.assertIsUserdata(channel.query "test")
2828
channel.destroy "test"
29-
lt.assertErrorMsgEquals("Can't query channel 'test'", channel.query, "test")
29+
lt.assertIsNil(channel.query "test")
3030
channel.create "test"
3131
lt.assertIsUserdata(channel.query "test")
3232
channel.destroy "test"

0 commit comments

Comments
 (0)