Hi All,
I am learning sputnik, and try to make it works with lua5.2. In its wsapi_app.lua, it handles the error message with coxpcall (which is an alias of xpcall in lua5.2). Code is following:
local function make_safer_app(app_function, error_app_function)
return function(wsapi_env, err)
local ok, status, headers, fn = coxpcall(
function() return app_function(wsapi_env, err) end,
function(e) return error_app_function(wsapi_env, e) end
)
return status, headers, fn
end
end
Whenever the errors happened in app_functoin, the error_app_function tries to catch it, and construct an error response. But this make_safer_app returns the 'status', 'headers' 'fn' which are returned from coxpcall/xpcall, which means when error_app_function been called the headers, fn will be nil for sure. The response object constructed in error_app_function only brings the status, as any other returns droped.
Is there a pretty way to get the headers, fn from the error_app_function?