Proper stack tracing

So, while I’m still working on my event handler, I’m curious on how to control stack tracing.

Lets say for instance, I have a function that calls another function:

local function a()
    error("This shouldn't go past b", 3);
end

local function b()
    a();
end

b();

As we know, if the error level is past the stack, then it will not stacktrace it, just like setting the level to 0. So, how do I prevent the stack level from going past b, or in this case, 2?

How does Roblox do this in their Event handler? If you set the level past the :Connect function, it will not stacktrace it.
image

debug.traceback() if you weren’t aware of it already.

That’s to get the trace, not limit it

coroutines don’t unwrap the active function stack upon an error occurring.

So how does roblox do it then?

No, I mean use coroutines if you want to limit the traceback.

1 Like

Thanks for the help!