debug.traceback missing top level plugin information

Posted by Fiendish on Tue 22 Dec 2015 02:32 PM — 2 posts, 10,430 views.

USA Global Moderator #0
A plugin has:


require "foo.lua"

function OnPluginInstall()
   foo.do_a_thing(5)
end


foo.lua has

function do_a_thing(a)
   return(check_errors(a))
end

function check_errors(b)
   print(debug.traceback())
end


What gets printed is:
Quote:

stack traceback:
...\MUSHclient\lua\foo.lua:71: in function 'do_a_thing'
[string "Plugin"]:13: in function <[string "Plugin"]:12>


Notice that there is no given information about OnPluginInstall or the plugin name.

If I replace OnPluginInstall with

function OnPluginInstall()
   test()
end

function test()
   foo.do_a_thing(5)
end


Then the traceback shows

Quote:

stack traceback:
...\MUSHclient\lua\foo.lua:71: in function 'do_a_thing'
[string "Plugin"]:17: in function 'test'
[string "Plugin"]:13: in function <[string "Plugin"]:12>


<[string "Plugin"]:12> isn't super useful information
Australia Forum Administrator #1
Added the plugin name to the internal information Lua holds, eg. "Plugin: foo".

https://github.com/nickgammon/mushclient/commit/574cab1