SpaceBeeGaming 3 Posted December 26, 2018 Share Posted December 26, 2018 So, I'm developing a program which uses event.listen(), and debugging them is a pain because of lines like these: bad argument #1 (string expected, got nil) How am I supposed to know where the error is when there is no location information? So is there a way to get the full error details somehow? Quote Link to post Share on other sites
0 Solution Ta©ti Tac0Z 2 Posted December 26, 2018 Solution Share Posted December 26, 2018 the function xpcall should give you a traceback witch will tell you what line the error is genratet usage: syc, e = xpcall(functionToRun, debug.traceback) --[[ syc: true or false: where false means that there was an error e: a full error message i.e: line bla-bla-bla: bad argument bla-bla-bla traceback: at line bla-bla-bla in function bla-bla-bla ... ]] Quote Link to post Share on other sites
0 SpaceBeeGaming 3 Posted December 26, 2018 Author Share Posted December 26, 2018 Decided to change temporarily to event.pull() but thanks anyway. Quote Link to post Share on other sites
0 Ta©ti Tac0Z 2 Posted December 26, 2018 Share Posted December 26, 2018 also treads doesn't create an critical error in the main scope so a great way to run a thread in terms of debuging is by printing the error on the screen and start a blocking function such as computer.beep() funciton runThreadWithExelentDebuging(func) thread.create(function() local syc, e = xpcall(func, debug.traceback) if syc == false then //syc is false this means an error was genrated in func require("term").clear() print(e) require("computer").beep(500,10) //calling computer.beep to avoid other threads or the main scope to redraw the screen end end) end --disclamer: this is not tested Quote Link to post Share on other sites
So, I'm developing a program which uses event.listen(), and debugging them is a pain because of lines like these:
bad argument #1 (string expected, got nil)
How am I supposed to know where the error is when there is no location information? So is there a way to get the full error details somehow?
Link to post
Share on other sites