Is there a way to check if the gosub stack is empty?
The goal is avoid to call Return if the stack is empty because it causes an error on execution:
-- Executing [351@usuarios:4] Return("PJSIP/203-00000010", "") in new stack}} -- [2019-07-01 11:33:26.972] ERROR[C-00000009]: app_stack.c:389 return_exec: Return without Gosub: stack is unallocated
In my case, the same extension can be called directly or via Gosub from other contexts (for avoiding duplication), the problem is when the call is directly placed because the stack is empty and I will get an error.
Replacing the calls with Goto is not possible because I need to continue the dialplan execution when calling from other contexts.
I saw the StackPop application but it doesn’t fit the needs because remove elements from stack.
I could control with custom variables but I was looking for a more elegant way.