diff options
author | sinanmohd <sinan@sinanmohd.com> | 2023-10-02 16:20:37 +0530 |
---|---|---|
committer | sinanmohd <sinan@sinanmohd.com> | 2023-10-02 16:20:37 +0530 |
commit | 18d923e2c36e0c901dc75e34c26b74bafa040e5c (patch) | |
tree | 1df0d0e5cd8cec33d630d497954ff3524e173a9a /lib/curl.lua | |
parent | 50a50ffa59608838e21e63ba288f584be21a1c08 (diff) |
repo: refactor error logging
Diffstat (limited to 'lib/curl.lua')
-rw-r--r-- | lib/curl.lua | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/curl.lua b/lib/curl.lua index a152bd0..04ebf95 100644 --- a/lib/curl.lua +++ b/lib/curl.lua @@ -46,7 +46,7 @@ local get = function (url, headr, args) end local zip_link_to_file = function (url, headr, out, retries) - local tries, hcode, zip, zcode + local tries, hcode, zip, rc tries = 0 zip = os.tmpname() @@ -54,14 +54,19 @@ local zip_link_to_file = function (url, headr, out, retries) repeat _, hcode = get(url, headr, { '-o'.. zip }) tries = tries + 1 - until hcode == 200 or tries > retries + until hcode == 200 or not hcode or tries > retries + rc = (hcode == 200) - if hcode == 200 then - zcode = util.zip_ext_first(zip, out) + if rc then + rc = util.zip_ext_first(zip, out) end os.remove(zip) - return (hcode == 200) and zcode + if hcode and not rc then + util.error('curl: zip_link_to_file') + end + + return rc end return { |