WeaselGames / godot_luaAPI

Godot LuaAPI
https://luaapi.weaselgames.info
Other
371 stars 28 forks source link

Add Signal for all errors that occure in a Lua state #105

Closed RadiantUwU closed 1 year ago

RadiantUwU commented 1 year ago

Is your feature request related to a problem? Please describe. The problem is that you cannot currently know if an error has occurred, debug doesn't know, Lua doesn't know. This happens only when you do a call_function, it returns nil, but it doesn't specify that an error has occurred.

Describe the solution you'd like It would be very beneficial to have an error signal to specify when an error occurs, on which thread, message and the stack trace.

Describe alternatives you've considered It would probably work the same with an error flag, and a function to retrieve the error info (stack, message, coroutine, file, line, etc.)

RadiantUwU commented 1 year ago

Both could be combined, the signal returns an error info object

Trey2k commented 1 year ago

In what scenario is call_function not returning an error message? In theory if an error occurs it should be returned to you. https://github.com/WeaselGames/godot_luaAPI/blob/dd11bf9f57814622329925d6d3d9b6fa9a3b780e/src/luaState.cpp#L167-L187 Seems like push variant is not being properly handled. So that might cause an issue.

RadiantUwU commented 1 year ago

In what scenario is call_function not returning an error message? In theory if an error occurs it should be returned to you.

https://github.com/WeaselGames/godot_luaAPI/blob/dd11bf9f57814622329925d6d3d9b6fa9a3b780e/src/luaState.cpp#L167-L187

Seems like push variant is not being properly handled. So that might cause an issue.

Actually, i have not checked it, maybe it's the lack of documentation that made me think that?

Trey2k commented 1 year ago

Actually, i have not checked it, maybe it's the lack of documentation that made me think that?

Yeah, I just looked and the documentation isnt very clear with some methods. We should probably be more explicit on what methods can and can not return a LuaError. Because I agree this is not very clear atm: https://luaapi.weaselgames.info/v2.0-beta/classes/lua_api/#call_function

RadiantUwU commented 1 year ago

The feature request could still be done, so the outside environment is notified when Lua messes up.

Trey2k commented 1 year ago

The feature request could still be done, so the outside environment is notified when Lua messes up.

Potentially it could be, however it could also just as easily be be implemented on the end users side. The method mentioned is similar to what we used in v1 where you would define a error handling callback that would be called for all errors. It definitely works but we wanted to offer more control over error handling in general. I found the return on error method to be a good fit. I am open to discussion though.

RadiantUwU commented 1 year ago

Cannot be done - requires modification to lua's internal structure.