-
-
Notifications
You must be signed in to change notification settings - Fork 166
Allow erroring in LuaRequire returns #581
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
Comments
I would recommend opening FR directly in luau-lang/luau to get proper support from the language. |
Ah alright, though I think the advice they’ll say is to just use lua_error for this but it’s worth a shot ig |
For context, the reason I found out about this is because lute (c++ runtime) uses this strategy of using lua_error in require to error with user friendly errors like: |
In the require's navigator implementation they already have some (private) concept of errors, including error handler. |
So I asked someone in the Luau team and here is the response I got regarding this:
Overall, not so hopeful on them changing the API with a specific NavigateError as they seem to endorse lua_error right now but I'm willing to wait a bit for something more official too. The only issue I have personally with lua_error though is RawLua memory leaks so it'd be nice if those could be solved first somehow. Although I am unsure if the RawLua memory leaks are caused by luau require (which is where I believe the memory leaks usually start from) or from the use of RawLua itself, the whole issue has made me extremely scared of using RawLua in general especially where exceptions are involved... |
Apparently, it is safe to raise an error in a luau require method so it would be nice if NavigateError had a Error variant that just errors with said error. As for use-cases, better/more user friendly errors when handling typo'd registered modules or just doing resolution in general (e.g.
foo is not a valid builtin module
instead of@abc is not a valid alias
as an error etc.)I actually got this working on a fork of mlua which I'm planning of PRing for reference
The text was updated successfully, but these errors were encountered: