diff options
author | Matthew Wild <mwild1@gmail.com> | 2009-02-13 14:37:15 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2009-02-13 14:37:15 +0000 |
commit | 13fd316d82218961b88a4a3d96fa25f0ab41cc3d (patch) | |
tree | 17fb5e3663bf42fe6862841a4d6a2c1a4104950e | |
parent | 076dbdfa11ba01f89dd9539fa0912e0ded4b99ed (diff) | |
download | prosody-13fd316d82218961b88a4a3d96fa25f0ab41cc3d.tar.gz prosody-13fd316d82218961b88a4a3d96fa25f0ab41cc3d.zip |
Report errors in the config file to the user
-rw-r--r-- | core/configmanager.lua | 8 | ||||
-rwxr-xr-x | prosody | 18 |
2 files changed, 17 insertions, 9 deletions
diff --git a/core/configmanager.lua b/core/configmanager.lua index 075fcd3e..d0e70670 100644 --- a/core/configmanager.lua +++ b/core/configmanager.lua @@ -68,15 +68,15 @@ function load(filename, format) if f then local ok, err = parsers[format].load(f:read("*a")); f:close(); - return ok, err; + return ok, "parser", err; end - return f, err; + return f, "file", err; end if not format then - return nil, "no parser specified"; + return nil, "file", "no parser specified"; else - return nil, "no parser for "..(format); + return nil, "file", "no parser for "..(format); end end @@ -40,17 +40,25 @@ log = require "util.logger".init("general"); do -- TODO: Check for other formats when we add support for them -- Use lfs? Make a new conf/ dir? - local ok, err = config.load((CFG_CONFIGDIR or ".").."/prosody.cfg.lua"); + local ok, level, err = config.load((CFG_CONFIGDIR or ".").."/prosody.cfg.lua"); if not ok then print(""); print("**************************"); - print("Prosody was unable to find the configuration file."); - print("We looked for: "..(CFG_CONFIGDIR or ".").."/prosody.cfg.lua"); - print("A sample config file is included in the Prosody download called prosody.cfg.lua.dist"); - print("Copy or rename it to prosody.cfg.lua and edit as necessary."); + if level == "parser" then + print("A problem occured while reading the config file "..(CFG_CONFIGDIR or ".").."/prosody.cfg.lua"); + local err_line, err_message = tostring(err):match("%[string .-%]:(%d*): (.*)"); + print("Error"..(err_line and (" on line "..err_line) or "")..": "..(err_message or tostring(err))); + print(""); + elseif level == "file" then + print("Prosody was unable to find the configuration file."); + print("We looked for: "..(CFG_CONFIGDIR or ".").."/prosody.cfg.lua"); + print("A sample config file is included in the Prosody download called prosody.cfg.lua.dist"); + print("Copy or rename it to prosody.cfg.lua and edit as necessary."); + end print("More help on configuring Prosody can be found at http://prosody.im/doc/configure"); print("Good luck!"); print("**************************"); + print(""); os.exit(1); end end |