Page 1 of 1

option to catch all lua runtime errors

Posted: Mon Feb 05, 2018 11:34 am
by hreintke
Hi,

I am working on a mod that will provide a "scripted combinator".
That will allow for a player provided lua script to be excuted.

I use the lua xpcall() to prevent game crashes but some errors are still handled by the "game itself" (f.e. index out of bounds on signal parameters, nil value for entity elements).

Would like to catch all errors within the mod

Re: option to catch all lua runtime errors

Posted: Mon Feb 05, 2018 11:42 am
by steinio

Re: option to catch all lua runtime errors

Posted: Mon Feb 05, 2018 1:57 pm
by hreintke
Thanks for the pointer.

Checked the lua combinator mod but that will have the same problem.
It is using the pcall() to execute -> will also break

Re: option to catch all lua runtime errors

Posted: Mon Feb 05, 2018 2:44 pm
by eradicator
Can you provide an example (preferably /c pastable) for such a command whichs errors "leak" out of pcalls? I have some player command handling too and would like to test.

Re: option to catch all lua runtime errors

Posted: Mon Feb 05, 2018 6:38 pm
by hreintke
Hi,

I was wrong.
Made the error myself. The code in the xpcall is correctly protected as far as I can see now.

The crash occured when I was processing the function result in the main mod code which is not xpcall protected.

For now this closes my question, sorry for that.