From 798d72c90d7ab716bbc7fb5b32d57d0900f651c2 Mon Sep 17 00:00:00 2001 From: Wangchong Zhou Date: Wed, 30 Oct 2024 18:29:56 +0800 Subject: [PATCH] chore(pdk): set stack rewind to 3 to display the correct line when doing phase check --- kong/pdk/private/phases.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kong/pdk/private/phases.lua b/kong/pdk/private/phases.lua index d3a2bca57179..03d7fd168787 100644 --- a/kong/pdk/private/phases.lua +++ b/kong/pdk/private/phases.lua @@ -76,7 +76,7 @@ local function check_phase(accepted_phases) current_phase = PHASES.admin_api else error(fmt("no phase in ngx.ctx.KONG_PHASE, (need one of %s)", - table.concat(get_phases_names(accepted_phases), ", "))) + table.concat(get_phases_names(accepted_phases), ", ")), 3) end end @@ -89,7 +89,7 @@ local function check_phase(accepted_phases) error(fmt("function cannot be called in %s phase (only in: %s)", current_phase_name, - table.concat(accepted_phases_names, ", "))) + table.concat(accepted_phases_names, ", ")), 3) end @@ -101,7 +101,7 @@ local function check_not_phase(rejected_phases) local current_phase = ngx.ctx.KONG_PHASE if not current_phase then - error("no phase in ngx.ctx.KONG_PHASE") + error("no phase in ngx.ctx.KONG_PHASE", 3) end if band(current_phase, rejected_phases) == 0 then @@ -114,7 +114,7 @@ local function check_not_phase(rejected_phases) error(fmt("function cannot be called in %s phase (can be called in any " .. "phases except: %s)", current_phase_name, - table.concat(rejected_phases_names, ", "))) + table.concat(rejected_phases_names, ", ")), 3) end