Naturally I wonder what would happen if the script which handles script errors fails.
Possibly we could have a "error reporting" plugin whose job it is to do what you suggest, and which itself would not be called in the event of a script error.
I wonder what the best way of storing this stuff would be? Maybe a SQLite3 database which records stuff like:
* plugin name (if any)
* date/time
* what the error was
* what was called
* backtrace
More-or-less what appears in the main window, plus a timestamp in fact. Or maybe just a text file which is opened "append" and dump the stuff from the output window to it.
I'm not sure what you would do if some script error caused thousands of entries to be written to the database.
Something like this maybe (in the error.log file):
< date / time >
Run-time error
Plugin: Source_scanner (called from world: smaug2)
Immediate execution
[string "Plugin"]:41: The specified module could not be found.
stack traceback:
[C]: in function 'assert'
[string "Plugin"]:41: in main chunk
Error context in script:
37 :
38 : -- for opening editor and bringing it to the front
39 : -- available here: http://www.gammon.com.au/files/mushclient/lua5.1_extras/windows_utils.zip
40 :
41*: assert (package.loadlib ("windows_utils.dll", "luaopen_windows_utils")) ()
42 :
43 : require "alphanum"
44 : os.setlocale ("", "time")
45 :
[WARNING] C:\Program Files\MUSHclient\worlds\plugins\Source_scanner.xml
[WARNING] C:\Program Files\MUSHclient\worlds\smaug 2.MCL