Debug event handlers easier

Post Reply
User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Debug event handlers easier

Post by Vadi »

Event handlers don't properly report the Lua error (yet, until it's figured out...) but here's one easy workaround for it - wrap whats inside the function in a pcall.

So if you had:

Code: Select all

function myHandler()
	do_code()
end
Change it to:

Code: Select all

function myHandler()
local f = function ()
	do_code()
end

local status, msg = pcall(f)
if not status then
	display(msg)
end
end
That'll print any errors to the main window unfortunately, and not the error or debug views - but it's better than no error.

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Debug event handlers easier

Post by Vadi »

This is obsoleted now by newer Mudlet builds: http://forums.mudlet.org/viewtopic.php?f=5&t=1874

Post Reply