diff options
author | Andrew Lewis <nerf@judo.za.org> | 2016-11-22 10:36:26 +0200 |
---|---|---|
committer | Andrew Lewis <nerf@judo.za.org> | 2016-11-22 10:36:26 +0200 |
commit | 5b6955aff2fbff512108a8c76a0625bea4f7409a (patch) | |
tree | 65da19a16636b6c758f2ce89d32de5ad95a2b61c | |
parent | 919cbd477d499804b17c87656a435db6067ca31e (diff) | |
download | rspamd-5b6955aff2fbff512108a8c76a0625bea4f7409a.tar.gz rspamd-5b6955aff2fbff512108a8c76a0625bea4f7409a.zip |
[Minor] Clean up error handling in fuzzyconvert tool
-rw-r--r-- | src/rspamadm/fuzzy_convert.lua | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/src/rspamadm/fuzzy_convert.lua b/src/rspamadm/fuzzy_convert.lua index a7ee666b9..fb957907a 100644 --- a/src/rspamadm/fuzzy_convert.lua +++ b/src/rspamadm/fuzzy_convert.lua @@ -9,30 +9,26 @@ local function connect_redis(server, password, db) }) if not conn then - print('Cannot connect to ' .. server .. ' error: ' .. err) - return nil, err + return nil, 'Cannot connect: ' .. err end if password then ret = conn:add_cmd('AUTH', {password}) if not ret then - print('Cannot queue command. Error: ' .. err) - return nil, err + return nil, 'Cannot queue command' end end if db then ret = conn:add_cmd('SELECT', {db}) if not ret then - print('Cannot queue command. Error: ' .. err) - return nil, err + return nil, 'Cannot queue command' end end if password or db then ret, err = conn:exec() if not ret then - print('Cannot send commands to ' .. server .. ' error: ' .. err) - return nil, err + return nil, 'Cannot execute queued commands: ' .. err end end @@ -47,21 +43,21 @@ local function send_digests(digests, redis_host, redis_password, redis_db) end local ret for _, v in ipairs(digests) do - ret, err = conn:add_cmd('HMSET', { + ret = conn:add_cmd('HMSET', { 'fuzzy' .. v[1], 'F', v[2], 'V', v[3], }) if not ret then - print('Cannot batch HMSET command: ' .. err) + print('Cannot batch command') return false end - ret, err = conn:add_cmd('EXPIRE', { + ret = conn:add_cmd('EXPIRE', { 'fuzzy' .. v[1], tostring(v[4]), }) if not ret then - print('Cannot batch EXPIRE command: ' .. err) + print('Cannot batch command') return false end end @@ -81,7 +77,7 @@ local function send_shingles(shingles, redis_host, redis_password, redis_db) end local ret for _, v in ipairs(shingles) do - ret, err = conn:add_cmd('SET', { + ret = conn:add_cmd('SET', { 'fuzzy_' .. v[2] .. '_' .. v[1], v[4], }) @@ -89,12 +85,12 @@ local function send_shingles(shingles, redis_host, redis_password, redis_db) print('Cannot batch SET command: ' .. err) return false end - ret, err = conn:add_cmd('EXPIRE', { + ret = conn:add_cmd('EXPIRE', { 'fuzzy_' .. v[2] .. '_' .. v[1], tostring(v[3]), }) if not ret then - print('Cannot batch EXPIRE command: ' .. err) + print('Cannot batch command') return false end end @@ -113,20 +109,20 @@ local function update_counters(total, redis_host, redis_password, redis_db) return false end local ret - ret, err = conn:add_cmd('SET', { + ret = conn:add_cmd('SET', { 'fuzzylocal', total, }) if not ret then - print('Cannot batch SET command: ' .. err) + print('Cannot batch command') return false end - ret, err = conn:add_cmd('SET', { + ret = conn:add_cmd('SET', { 'fuzzy_count', total, }) if not ret then - print('Cannot batch SET command: ' .. err) + print('Cannot batch command') return false end ret, err = conn:exec() |