From ae9b9727ce06010a161fcb9c182a7efb2a29616e 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kong/pdk/private/phases.lua b/kong/pdk/private/phases.lua index 52e7ec40a22..db853ad635c 100644 --- a/kong/pdk/private/phases.lua +++ b/kong/pdk/private/phases.lua @@ -102,7 +102,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 @@ -115,7 +115,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