Software /
code /
prosody
Changeset
466:0ecfd89c2cc0
Fix for configmanager when config file can't be found
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 29 Nov 2008 03:26:46 +0000 |
parents | 465:9ab51c483cf3 |
children | 467:66f145f5c932 |
files | core/configmanager.lua |
diffstat | 1 files changed, 7 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/core/configmanager.lua Sat Nov 29 02:28:00 2008 +0000 +++ b/core/configmanager.lua Sat Nov 29 03:26:46 2008 +0000 @@ -2,6 +2,7 @@ local _G = _G; local setmetatable, loadfile, pcall, rawget, rawset, io = setmetatable, loadfile, pcall, rawget, rawset, io; + module "configmanager" local parsers = {}; @@ -52,18 +53,21 @@ function load(filename, format) format = format or filename:match("%w+$"); + if parsers[format] and parsers[format].load then - local f = io.open(filename); + local f, err = io.open(filename); if f then local ok, err = parsers[format].load(f:read("*a")); f:close(); return ok, err; end + return f, err; end + if not format then return nil, "no parser specified"; else - return false, "no parser"; + return nil, "no parser for "..(format); end end @@ -118,4 +122,4 @@ end -return _M; \ No newline at end of file +return _M;