Software /
code /
prosody
Changeset
13368:80a1ce9974e5
moduleapi: Log error message when ambiguous period spec is found in config
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 30 Nov 2023 13:43:23 +0000 |
parents | 13367:82513890a1d8 |
children | 13369:13a27043cd0f |
files | core/moduleapi.lua |
diffstat | 1 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/core/moduleapi.lua Thu Nov 30 13:42:44 2023 +0000 +++ b/core/moduleapi.lua Thu Nov 30 13:43:23 2023 +0000 @@ -281,7 +281,15 @@ 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));