Software / code / prosody
Comparison
core/moduleapi.lua @ 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 |
| parent | 13360:6037b7a2131c |
| child | 13514:a1bc6533bbba |
comparison
equal
deleted
inserted
replaced
| 13367:82513890a1d8 | 13368:80a1ce9974e5 |
|---|---|
| 279 -- assume seconds | 279 -- assume seconds |
| 280 ret = value; | 280 ret = value; |
| 281 elseif type(value) == "string" then | 281 elseif type(value) == "string" then |
| 282 ret = human_io.parse_duration(value); | 282 ret = human_io.parse_duration(value); |
| 283 if value ~= nil and ret == nil then | 283 if value ~= nil and ret == nil then |
| 284 self:log("error", "Config option '%s' not understood, expecting a period (e.g. \"2 days\")", name); | 284 ret = human_io.parse_duration_lax(value); |
| 285 if ret then | |
| 286 local num = value:match("%d+"); | |
| 287 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); | |
| 288 -- COMPAT: w/more relaxed behaviour in post-0.12 trunk. Return nil for this case too, eventually. | |
| 289 else | |
| 290 self:log("error", "Config option '%s' not understood, expecting a period (e.g. \"2 days\")", name); | |
| 291 return nil; | |
| 292 end | |
| 285 end | 293 end |
| 286 elseif value ~= nil then | 294 elseif value ~= nil then |
| 287 self:log("error", "Config option '%s' expects a number or a period description string (e.g. \"3 hours\"), not %s", name, type(value)); | 295 self:log("error", "Config option '%s' expects a number or a period description string (e.g. \"3 hours\"), not %s", name, type(value)); |
| 288 return nil; | 296 return nil; |
| 289 else | 297 else |