option to catch all lua runtime errors

Things that already exist in the current mod API
Post Reply
hreintke
Fast Inserter
Fast Inserter
Posts: 115
Joined: Mon Sep 04, 2017 6:52 pm
Contact:

option to catch all lua runtime errors

Post 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

User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2638
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: option to catch all lua runtime errors

Post by steinio »

Image

Transport Belt Repair Man

View unread Posts

hreintke
Fast Inserter
Fast Inserter
Posts: 115
Joined: Mon Sep 04, 2017 6:52 pm
Contact:

Re: option to catch all lua runtime errors

Post 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

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: option to catch all lua runtime errors

Post 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.

hreintke
Fast Inserter
Fast Inserter
Posts: 115
Joined: Mon Sep 04, 2017 6:52 pm
Contact:

Re: option to catch all lua runtime errors

Post 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.

Post Reply

Return to “Already exists”