@@ -22,6 +22,7 @@ function snax.interface(name)
22
22
local si = snax_interface (name , G )
23
23
24
24
local ret = {
25
+ name = name ,
25
26
accept = {},
26
27
response = {},
27
28
system = {},
@@ -44,7 +45,10 @@ local skynet_call = skynet.call
44
45
local function gen_post (type , handle )
45
46
return setmetatable ({} , {
46
47
__index = function ( t , k )
47
- local id = assert (type .accept [k ] , string.format (" post %s no exist" , k ))
48
+ local id = type .accept [k ]
49
+ if not id then
50
+ error (string.format (" post %s:%s no exist" , type .name , k ))
51
+ end
48
52
return function (...)
49
53
skynet_send (handle , " snax" , id , ... )
50
54
end
54
58
local function gen_req (type , handle )
55
59
return setmetatable ({} , {
56
60
__index = function ( t , k )
57
- local id = assert (type .response [k ] , string.format (" request %s no exist" , k ))
61
+ local id = type .response [k ]
62
+ if not id then
63
+ error (string.format (" request %s:%s no exist" , type .name , k ))
64
+ end
58
65
return function (...)
59
66
return skynet_call (handle , " snax" , id , ... )
60
67
end
0 commit comments