Skip to content

Errors in watch_for_file_changes are handled by crashing #30

@blobbyblob

Description

@blobbyblob

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)"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions