of     1   

noliCAIKS
#110700009Thursday, August 22, 2013 6:40 PM GMT

I created something that generates a stack trace for an error using the functions error and xpcall. This is impossible to do using the regular pcall or ypcall. This means, unfortunately, that I cannot currently generate a stack trace for functions that yield (for example by using wait). Therefore, I request an yxpcall (yielding xpcall) function that yields correctly like ypcall, but lets you use your own error handler like xpcall. Here's the code I used: function HandleError(errorMessage)         local buffer = {errorMessage}         local trace = StackTrace(5)         for index, details in ipairs(trace) do                 table.insert(buffer, string.format("Script '%s', Line %d", details[1], details[2]))         end         table.insert(buffer, "stack end")         return table.concat(buffer, "\n") end function StackTrace(level)         local trace = {}         while true do                 local success, errorMessage = pcall(error, "-", level)                 if errorMessage == "-" then                         return trace                 else                         local script, line = string.match(errorMessage, "(.*):(%d+)")                         table.insert(trace, {script, tonumber(line)})                         level = level + 1                 end         end end function F1()         error("Test") end function F2()         F1() end function F3()         F2() end function F4()         F3() end local success, errorMessage = xpcall(F4, HandleError) print(errorMessage) --[[ Output: Workspace.Stack Trace:25: Test Script 'Workspace.Stack Trace', Line 25 Script 'Workspace.Stack Trace', Line 28 Script 'Workspace.Stack Trace', Line 31 Script 'Workspace.Stack Trace', Line 34 stack end ]]--
robotmega
#110700131Thursday, August 22, 2013 6:42 PM GMT

inb4modsMind=Blown
AniDave
#110700145Thursday, August 22, 2013 6:42 PM GMT

I totally never though of this as an issue until now. Support.
noliCAIKS
#110701066Thursday, August 22, 2013 6:51 PM GMT

Small note in case you actually want to use my StackTrace function, the function itself is also on the stack so you should add two to the actual level you want to use. So basically, StackTrace(3) generates a stack trace for the function that calls it. You can fix this by puting `level = level + 2' on the first line of the StackTrace function.
AntiBoomz0r
#110704792Thursday, August 22, 2013 7:30 PM GMT

Panda supports.
booing
#110713743Thursday, August 22, 2013 8:46 PM GMT

Support
qlqkqzqrd
#110717796Thursday, August 22, 2013 9:20 PM GMT

I support with this reply
LegoPro10
#110721022Thursday, August 22, 2013 9:47 PM GMT

Suppaort
toshir0z
#110730031Thursday, August 22, 2013 11:02 PM GMT

Support +1
BlooFrog
#110730234Thursday, August 22, 2013 11:04 PM GMT

I don't understand what you are trying to implement, but it looks complicated, so support!
Ilbanium
#110812126Friday, August 23, 2013 5:45 PM GMT

I support.
SecantFuture
#110938987Saturday, August 24, 2013 7:45 PM GMT

supp0rt
[rfa#hidefromsearch]
#110940114Saturday, August 24, 2013 7:55 PM GMT

[rfa#hidefromsearch]
TehEpicFaic
#110949745Saturday, August 24, 2013 9:31 PM GMT

Support. Shouldn't be too hard.
HEAT507
#110952983Saturday, August 24, 2013 10:02 PM GMT

support with this.
Rhyles
#196767711Monday, August 22, 2016 3:31 PM GMT

support!

    of     1