# HG changeset patch # User JC Brand # Date 1465913610 0 # Node ID 126d79bf079b65933daf586a900bd0e4f20a09f7 # Parent 95a9f2d234da0d9585a649f5df78ec8ca0881468 mod_http_roster_admin: Also log if the status error is 0 (Connection refused) (Also replaced spaced indentation with tabs, as is the convention) diff -r 95a9f2d234da -r 126d79bf079b mod_http_roster_admin/mod_http_roster_admin.lua --- a/mod_http_roster_admin/mod_http_roster_admin.lua Fri Apr 15 16:59:27 2016 +0000 +++ b/mod_http_roster_admin/mod_http_roster_admin.lua Tue Jun 14 14:13:30 2016 +0000 @@ -125,23 +125,25 @@ -- Fetch the named user's roster from the API, call callback (cb) -- with status and result (friends list) when received. function fetch_roster(username, cb) - local x = {headers = {}}; - x["headers"]["ACCEPT"] = "application/json, text/plain, */*"; + local x = {headers = {}}; + x["headers"]["ACCEPT"] = "application/json, text/plain, */*"; local ok, err = http.request( - roster_url:format(username), - x, - function (roster_data, code) - if code ~= 200 then - if code ~= 0 then - module:log("error", "Error fetching roster from %s (code %d): %s", roster_url:format(username), code, tostring(roster_data):sub(1, 40):match("^[^\r\n]+")); - cb(nil, code, roster_data); - end - return; - end - module:log("debug", "Successfully fetched roster for %s", username); - module:log("debug", "The roster data is %s", roster_data); - cb(true, code, json.decode(roster_data)); - end); + roster_url:format(username), + x, + function (roster_data, code) + if code ~= 200 then + module:log("error", "Error fetching roster from %s (code %d): %s", roster_url:format(username), code, tostring(roster_data):sub(1, 40):match("^[^\r\n]+")); + if code ~= 0 then + cb(nil, code, roster_data); + end + return; + end + module:log("debug", "Successfully fetched roster for %s", username); + module:log("debug", "The roster data is %s", roster_data); + cb(true, code, json.decode(roster_data)); + end + ); + module:log("debug", "fetch_roster: ok is %s", ok); if not ok then module:log("error", "Failed to connect to roster API at %s: %s", roster_url:format(username), err); cb(false, 0, err);