【发布时间】:2021-10-23 14:33:03
【问题描述】:
我要避免的是在 FFI 调用不存在的方法时捕获/忽略异常。
例如,以下代码调用non_existent_method。但是,pcall 无法处理该错误。
local ffi = require "ffi"
local C = ffi.C
ffi.cdef [[
int non_existent_method(int num);
]]
local ok, ret = pcall(C.non_existent_method, 1)
if not ok then
return
end
OpenResty/lua-nginx-module 出现以下错误。
lua entry thread aborted: runtime error: dlsym(RTLD_DEFAULT, awd): symbol not found
【问题讨论】:
-
当您使用键
non_existent_method索引C时会发生错误。