]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
utils: add human-readable text to HTTP client library errors
authorPetr Špaček <petr.spacek@nic.cz>
Mon, 30 Dec 2019 15:56:11 +0000 (16:56 +0100)
committerLukáš Ježek <lukas.jezek@nic.cz>
Tue, 7 Jan 2020 10:02:32 +0000 (11:02 +0100)
daemon/lua/kluautil.lua

index d0cca438f3ef835fe4717854b56784efcc6334f9..fa962026911c095f5a3a2c682cc333183512b759 100644 (file)
@@ -1,3 +1,4 @@
+local cqerrno = require('cqueues.errno')
 local kluautil = {}
 
 -- Get length of table
@@ -39,6 +40,10 @@ function kluautil.kr_https_fetch(url, out_file, ca_file)
        local headers, stream, errmsg = req:go()
        if not headers then
                errmsg = errmsg or 'unknown error'
+               if type(errmsg) == 'number' then
+                       errmsg = cqerrno.strerror(errmsg) ..
+                               ' (' .. tostring(errmsg) .. ')'
+               end
                return nil, 'HTTP client library error: ' .. errmsg
        end
        if headers:get(':status') ~= "200" then