comparison core/moduleapi.lua @ 14101:3e6bb6ffbd43 13.0

core.moduleapi: Use default value when enum option has incorrect value Is an error without consequences even an error?
author Kim Alvefur <zash@zash.se>
date Wed, 11 Mar 2026 16:53:48 +0100
parents 4309c934e813
children a124e80d3498 374b72785488
comparison
equal deleted inserted replaced
14100:7fd6feb86dbe 14101:3e6bb6ffbd43
398 local value = self:get_option_scalar(name, default); 398 local value = self:get_option_scalar(name, default);
399 if value == nil then return nil; end 399 if value == nil then return nil; end
400 local options = set.new{default, ...}; 400 local options = set.new{default, ...};
401 if not options:contains(value) then 401 if not options:contains(value) then
402 self:log("error", "Config option '%s' not in set of allowed values (one of: %s)", name, options); 402 self:log("error", "Config option '%s' not in set of allowed values (one of: %s)", name, options);
403 return default;
403 end 404 end
404 return value; 405 return value;
405 end 406 end
406 407
407 function api:context(host) 408 function api:context(host)