Mercurial > prosody-hg
comparison core/configmanager.lua @ 14129:6da8b3db84de 13.0
configmanager: Return errno (if any) for file opening errors
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Thu, 16 Apr 2026 18:49:04 +0100 |
| parents | f0d854c63c8d |
| children |
comparison
equal
deleted
inserted
replaced
| 14128:0235fee459d0 | 14129:6da8b3db84de |
|---|---|
| 88 | 88 |
| 89 function _M.load(filename, config_format) | 89 function _M.load(filename, config_format) |
| 90 config_format = config_format or filename:match("%w+$"); | 90 config_format = config_format or filename:match("%w+$"); |
| 91 | 91 |
| 92 if config_format == "lua" then | 92 if config_format == "lua" then |
| 93 local f, err = io.open(filename); | 93 local f, err, errno = io.open(filename); |
| 94 if f then | 94 if f then |
| 95 local new_config = setmetatable({ ["*"] = { } }, config_mt); | 95 local new_config = setmetatable({ ["*"] = { } }, config_mt); |
| 96 local ok, err = parser.load(f:read("*a"), filename, new_config); | 96 local ok, err = parser.load(f:read("*a"), filename, new_config); |
| 97 f:close(); | 97 f:close(); |
| 98 if ok then | 98 if ok then |
| 99 config = new_config; | 99 config = new_config; |
| 100 end | 100 end |
| 101 return ok, "parser", err; | 101 return ok, "parser", err; |
| 102 end | 102 end |
| 103 return f, "file", err; | 103 return f, "file", err, errno; |
| 104 end | 104 end |
| 105 | 105 |
| 106 if not config_format then | 106 if not config_format then |
| 107 return nil, "file", "no parser specified"; | 107 return nil, "file", "no parser specified"; |
| 108 else | 108 else |
