-- require local result = require "utils.result" local _M = { _VERSION = '0.01', err_code = "E_0001"} --[[ -- custom log output, xpcall error handler -- Operations such as ngx.exit cannot be used in functions -- @param _errmsg exception information --]] function _M.write_error(_errmsg) _M.track_text = debug.traceback(tostring(_errmsg), 6) ngx.log (ngx.ERR, _M.track_text) end -- equal try catch function _M:trycall(_func) xpcall(_func, self.write_error) return result:error(_M.err_code, _M.track_text) end return _M
openresty lua xpcall exception handler loop is executed
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=326266618&siteId=291194637
Recommended
Ranking