Lua/factorio generate somewhat misleading error messages

Bugs that are actually features.
jagholin
Inserter
Inserter
Posts: 32
Joined: Mon Jan 06, 2020 7:19 pm
Contact:

Lua/factorio generate somewhat misleading error messages

Post by jagholin »

As an example, https://i.imgur.com/diQeKTh.png

"value must be a string in property tree at ... localised_description[0]".

Except that there is no localised_description[0]. Arrays in Lua start with elements at index 1, and go up from there.

Suggestion: increment array indices by 1 when generating lua error messages.

So it should read,

"value must be a string ... localised_description[1]"
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3953
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: Lua/factorio generate somewhat misleading error messages

Post by boskid »

Thanks for the report, however i am not considering this to be a bug.

PropertyTree is mainly a c++ side structure so if there are any Lua data converted into PropertyTree, at this stage those indexes are reduced by 1. Having a PropertyTree be aware if they come from Lua or from other structures only to be able to adjust indexes, and then be aware if they are throwing in a Lua-like context or a c++-like context seems mostly unproductive. A note on the wiki that PropertyTree is 0-indexed should be enough.
jagholin
Inserter
Inserter
Posts: 32
Joined: Mon Jan 06, 2020 7:19 pm
Contact:

Re: Lua/factorio generate somewhat misleading error messages

Post by jagholin »

I understand your point, but i want to suggest a counter-argument.

I think the question to ask is, to whom is this error message addressed? Is it
a. factorio developers
b. mod developers/normal users.

If it's primarily a., you may disregard this post. However I argue that it's b., and as such it should always be assumed that the error originates in a lua context. Mod devs only ever have access to Lua side of things, and any users are likely to send this error message to the mod authors. It even helpfully details the mods involved, so there is some tracking infrastructure already in place, but maybe not granular enough to make a definite decision in all cases.
Post Reply

Return to “Not a bug”