mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-25 16:53:46 +01:00
Configuration/schema: Fix handling of failed checks
This commit is contained in:
parent
98bd1741ad
commit
76a17be124
3
mod.lua
3
mod.lua
@ -55,6 +55,7 @@ function configuration(modname)
|
||||
modname = modname or minetest.get_current_modname()
|
||||
local schema = modlib.schema.new(assert(include(modname, "schema.lua")))
|
||||
schema.name = schema.name or modname
|
||||
local settingtypes = schema:generate_settingtypes()
|
||||
assert(schema.type == "table")
|
||||
local overrides = {}
|
||||
local conf
|
||||
@ -105,7 +106,7 @@ function configuration(modname)
|
||||
overrides = modlib.table.deep_add_all(overrides, minetest_conf)
|
||||
conf = schema:load(overrides, {convert_strings = true, error_message = true})
|
||||
end
|
||||
modlib.file.ensure_content(get_resource(modname, "settingtypes.txt"), schema:generate_settingtypes())
|
||||
modlib.file.ensure_content(get_resource(modname, "settingtypes.txt"), settingtypes)
|
||||
local readme_path = get_resource(modname, "Readme.md")
|
||||
local readme = modlib.file.read(readme_path)
|
||||
if readme then
|
||||
|
@ -226,8 +226,7 @@ function load(self, override, params)
|
||||
local function error(type, ...)
|
||||
if params.error_message then
|
||||
local formatted = format_error(type, ...)
|
||||
settingtypes(self)
|
||||
_error("Invalid value: " .. self.name .. ": " .. formatted)
|
||||
_error("Invalid value: " .. (self.name and (self.name .. ": ") or "") .. formatted)
|
||||
end
|
||||
_error{
|
||||
type = type,
|
||||
|
Loading…
Reference in New Issue
Block a user