Calling gi.require may not always succeed. If we do not wrap it in an assert, we will get confusing error messages.
For example, a failure in lgi/ffi.lua would look like:
attempt to index local 'gobject' (a boolean value)
wrapping gi.require with assert instead would show a more informative message:
Typelib file for namespace 'win32', version '1.0' not found
This change updates both lgi/class.lua and lgi/ffi.lua which appear to be the only two files in the codebase that do not wrap gi.require with an assert.
Fixes #71
Calling gi.require may not always succeed. If we do not wrap it in an
assert
, we will get confusing error messages.For example, a failure in
lgi/ffi.lua
would look like:wrapping
gi.require
withassert
instead would show a more informative message:This change updates both
lgi/class.lua
andlgi/ffi.lua
which appear to be the only two files in the codebase that do not wrapgi.require
with anassert
.A practical example where this would have been useful is https://github.com/NixOS/nixpkgs/issues/139159#issuecomment-2156172046
I actually managed to figure out the issue with NixOS using this patch.
Thanks for developing and maintaining lgi!