From fa09978a11164835122adfa2d3b69cf4fe82122d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Manh=C3=A3es?= <gabrielmanhaes@tecgraf.puc-rio.br> Date: Wed, 25 Mar 2020 14:40:08 -0300 Subject: [PATCH] =?UTF-8?q?Tratando=20erro=20pra=20sga=5Fname=20j=C3=A1=20?= =?UTF-8?q?definido=20no=20arquivo=20de=20configura=C3=A7=C3=A3o=20[SOMA-3?= =?UTF-8?q?827][SOMA-4074]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sga/configuration.lua | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/sga/configuration.lua b/sga/configuration.lua index fded807..c7b0599 100644 --- a/sga/configuration.lua +++ b/sga/configuration.lua @@ -26,24 +26,20 @@ local function get_from_multiple(filename, sga_name, config) if not sga_name then return nil, string.format(err, filename, "missing sga_name argument") end - - if config.sga_name then - -- TODO: Dar erro se config default tiver sga_name - config.sga_name = nil - end - local config_data = config.sga[sga_name] if not config_data then return nil, string.format(err, filename, "'"..sga_name.."' not found") end config.sga = nil -- avoid multiple inside multiple - + config, err = get(config_data, filename, config) if not config then return nil, string.format("[%s] %s", sga_name, err) end + if config.sga_name then + return nil, string.format("sga_name '"..config.sga_name.."' already defined in configuration file "..filename) + end - -- TODO: Dar erro se config do sga escolhido tiver sga_name config.sga_name = sga_name return config -- GitLab