Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make error message in require more descriptive for custom LOVE library loader. #1865

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MikuAuahDark
Copy link
Contributor

This PR adds paths that LOVE tried to load when require fails in the error message.

The new output will look like this:

Error

main.lua:1: module 'path.to.module' not found:
no field package.preload['path.to.module']
no 'path/to/module' in LOVE game directories:
  tried 'path/to/module.lua'
  tried 'path/to/module/init.lua'
no file 'path/to/module' in LOVE paths:
  tried 'path/to/module.dll' in save directory
no file '.\path\to\module.lua'
no file 'D:\Data\Development\love-dev\install-11\lua\path\to\module.lua'
no file 'D:\Data\Development\love-dev\install-11\lua\path\to\module\init.lua'
no file '.\path\to\module.dll'
no file 'D:\Data\Development\love-dev\install-11\path\to\module.dll'
no file 'D:\Data\Development\love-dev\install-11\loadall.dll'
no file '.\path.dll'
no file 'D:\Data\Development\love-dev\install-11\path.dll'
no file 'D:\Data\Development\love-dev\install-11\loadall.dll'

Fixes #1864

@@ -828,7 +834,10 @@ int extloader(lua_State *L)

Filesystem::Info info = {};
if (!inst->getInfo(element.c_str(), info) || info.type == Filesystem::FILETYPE_DIRECTORY)
{
errstr << "\n\t tried '" << element << "' in save directory";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this isn't guaranteed to only look (or work) in the save directory right now, especially if love 12's new mount APIs have been used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be a good replacement text for those?

Copy link
Member

@slime73 slime73 Nov 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it could be something like this for the Lua loader:

No Lua code 'path/to/module' in LOVE filesystem paths:
  tried 'path/to/module.lua'

And for the C module loader:

No C library 'path/to/module' in LOVE filesystem paths:
  tried 'path/to/module.dll'

Does that make sense? I haven't thought about this too hard. Maybe the language could still be tweaked a bit...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the C module paths, I was thinking of resolving the fullpath then printing the absolute path, but then I realize PHYSFS_getRealDir only works when the file is there (which most likely succeeded when this codepath is reached, defeating the purpose).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve require Error Message
2 participants