aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2023-11-30 13:43:23 +0000
committerMatthew Wild <mwild1@gmail.com>2023-11-30 13:43:23 +0000
commit2132eca2e013346321c403c279a02031560b05ca (patch)
tree0773c8c97c72a61cff544955c742e1ebc3f03431
parenta669ffb5a2ea3d73e7f7c460deef52579d5ba57b (diff)
downloadprosody-2132eca2e013346321c403c279a02031560b05ca.tar.gz
prosody-2132eca2e013346321c403c279a02031560b05ca.zip
moduleapi: Log error message when ambiguous period spec is found in config
-rw-r--r--core/moduleapi.lua10
1 files changed, 9 insertions, 1 deletions
diff --git a/core/moduleapi.lua b/core/moduleapi.lua
index 06aec5c2..31d1b1bd 100644
--- a/core/moduleapi.lua
+++ b/core/moduleapi.lua
@@ -281,7 +281,15 @@ function api:get_option_period(name, default_value, min, max)
elseif type(value) == "string" then
ret = human_io.parse_duration(value);
if value ~= nil and ret == nil then
- self:log("error", "Config option '%s' not understood, expecting a period (e.g. \"2 days\")", name);
+ ret = human_io.parse_duration_lax(value);
+ if ret then
+ local num = value:match("%d+");
+ self:log("error", "Config option '%s' is set to ambiguous period '%s' - use full syntax e.g. '%s months' or '%s minutes'", name, value, num, num);
+ -- COMPAT: w/more relaxed behaviour in post-0.12 trunk. Return nil for this case too, eventually.
+ else
+ self:log("error", "Config option '%s' not understood, expecting a period (e.g. \"2 days\")", name);
+ return nil;
+ end
end
elseif value ~= nil then
self:log("error", "Config option '%s' expects a number or a period description string (e.g. \"3 hours\"), not %s", name, type(value));