From 057d487ee7de995da8a5e667f1ed4c21bca2dcb8 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Tue, 2 Feb 2016 19:08:19 +0300 Subject: [PATCH 1/2] Fix. Do not build context if there error. --- .../resources/scripts/dialplan/dialplan.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/resources/install/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua b/resources/install/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua index d07f6090f8..1925250d38 100644 --- a/resources/install/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua +++ b/resources/install/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua @@ -108,8 +108,12 @@ if (debug["sql"]) then log.notice("SQL: " .. sql); end - x = 0; + local x = 0; + local pass dbh:query(sql, function(row) + --clear flag pass + pass = false + --get the dialplan domain_uuid = row.domain_uuid; dialplan_uuid = row.dialplan_uuid; @@ -281,8 +285,16 @@ --increment the x x = x + 1; + + --set flag pass + pass = true end); + -- prevent partial dialplan (pass=nil may be error in sql or empty resultset) + if pass == false then + error('error while build context: ' .. call_context) + end + --close the extension tag if it was left open if (dialplan_tag_status == "open") then table.insert(xml, [[ ]]); From 48b3aa2917d3422fe2a39c3f38a55b0825eb6e59 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Tue, 2 Feb 2016 19:32:27 +0300 Subject: [PATCH 2/2] Add. debug message to log. --- .../resources/scripts/dialplan/dialplan.lua | 10 ++++++++++ resources/install/scripts/resources/functions/log.lua | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/resources/install/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua b/resources/install/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua index 1925250d38..55f479aed5 100644 --- a/resources/install/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua +++ b/resources/install/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua @@ -292,6 +292,16 @@ -- prevent partial dialplan (pass=nil may be error in sql or empty resultset) if pass == false then + log.errf('context: %s, extension: %s, type: %s, data: %s ', + call_context, + dialplan_name or '----', + dialplan_detail_tag or '----', + dialplan_detail_data or '----' + ) + + --close the database connection + dbh:release(); + error('error while build context: ' .. call_context) end diff --git a/resources/install/scripts/resources/functions/log.lua b/resources/install/scripts/resources/functions/log.lua index eb73e5c13c..5b60091484 100644 --- a/resources/install/scripts/resources/functions/log.lua +++ b/resources/install/scripts/resources/functions/log.lua @@ -42,7 +42,7 @@ local function tracef(type, name, level, ...) end local LEVELS = { - 'error', + 'err', 'warning', 'notice', 'info',