When an error is encountered in the callback for watch_for_file_changes, the program will crash saying lua5.1.exe has stopped working rather than providing a useful error message. Repro:
require("winapi")
watcher, err = winapi.watch_for_file_changes(
".",
winapi.FILE_NOTIFY_CHANGE_LAST_WRITE,
false,
function() oops_not_a_function(); end
);
local file = io.open("out.txt", "w")
file:write("foobar")
file:close()
winapi.sleep(100)
A similar experience can be had by passing in nil for the function callback.
It would be much more useful if the error would be handled like errors encountered during regular execution, that is, providing a message: "test.lua:7: attempt to call global 'oops_not_a_function' (a nil value)"
When an error is encountered in the callback for
watch_for_file_changes, the program will crash sayinglua5.1.exe has stopped workingrather than providing a useful error message. Repro:A similar experience can be had by passing in
nilfor the function callback.It would be much more useful if the error would be handled like errors encountered during regular execution, that is, providing a message: "test.lua:7: attempt to call global 'oops_not_a_function' (a nil value)"