This is pretty straightforward, if I have a localscript that only has error("Test", 0) inside of it, the script will run, the console will log “Test” but it also log the stack trace despite the level being set to 0.
Is there another way to reach stackless errors?
I’ve also tried task.wait with 0, still shows a stack.
This is an intentional and a documented part of Lua. The only difference between using a level of 1 and 0 is whether or not the error position (line #) is part of the error message.
You can still see it printing the line number though, I passed 0 into the error function.
However, I was looking around a few games and I can see some of them having some sort of notification message being printed out in the console with 0 stack trace.
I will provide an example from a core game that I am a community member in.
Ignoring the warnings, there is no stack trace attached to the error printed out at 14:38:18.
Although this is more of a help request that I already made a post about, however no one was able to figure it out. Maybe people here can?
That line number is part of the trace, not the error message. Passing 0 hides it from the error message and not the trace. Your screenshot seems to be cut off so I’m not sure if you’re saying there is a line number at the end of it that I can’t see.
If you ask me, I dont think this behaviour should be inherited into Luau.
The level argument changes what caused the error, for example, an invalid type should trail up the stack to the caller, not the function itself.
This also creates a bug with the error logs in the output, if you use error(…, 2), it creates an anchor to the wrong function, because it always uses the top of the stack trace.
Now for feasibility, I’m unsure given that the stack trace itself when you throw is unaware of the error level arg, so, /shrug
Ah I see.
I’ll mark your answer as a solution then since I guess it was a misunderstanding.
Follow up question to that, is it possible to print an error message with no line in the error message and no stack trace, as posted in the original post (and the screenshot I attached above your message)?
If you really want to get rid of as much of the stack trace as possible (you shouldn’t! it will make errors harder to debug), you can call error in a new thread, task.spawn(error, "error message") but this will also have the effect of not interrupting the current thread which kind of defeats the purpose.