# HG changeset patch # User Matthew Wild # Date 1227929206 0 # Node ID 0ecfd89c2cc0932e0429ebfe5e526a43485c6fe7 # Parent 9ab51c483cf33f20ddb4dbbd2f6a82efeae039f7 Fix for configmanager when config file can't be found diff -r 9ab51c483cf3 -r 0ecfd89c2cc0 core/configmanager.lua --- 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;