Page 1 of 1

[closed] Dump data.raw to log if terror in data stage

Posted: Sat Oct 01, 2016 12:08 am
by aubergine18
Would it be possible for the game to automatically dump data.raw to the log file if there's an error in data stage (if possible, just the section of data.raw that relates to the problem)?

While I can potentially use pcall or xpcall to trap the error and dump like this...

Code: Select all

serpent.block( tank, {comment = false, numformat = '%1.8g' } )
...it will generate so much information that finding the error will be like searching for a needle in a haystack.

As the game knows which entity, item, or whatever chunk of data.raw it's processing when the error occurs, it could potentially just dump that specific chunk of data.raw to the log file to make debugging much easier.

Re: Dump data.raw to log if there's an error in data stage

Posted: Sat Oct 01, 2016 2:16 pm
by Adil
I'm dealing with such errors manually. Probably an automatic dump will save some time.

Actually, you can't do that x/pcall thing. All prototype definitions are just arbitrary lua tables, you can write in and do whatever with them.
data:extend is just packing them into a bigger table (and maybe checks for type and name missing, iirc).
The errors start popping out when c++ dataloader gets fed the data table, and that happens after all the data scripts in every mod have been run, thus it is beyond of your lua_state.

Re: Dump data.raw to log if there's an error in data stage

Posted: Sat Oct 01, 2016 7:15 pm
by Rseding91
The error(s) tell you what prototype caused the error and what the error was. That's always enough to tell you what you need to fix.

What error(s) are you getting that you can't determine the cause of them?

Re: Dump data.raw to log if there's an error in data stage

Posted: Sat Oct 01, 2016 7:38 pm
by Nexela
While I can't answer for aubergine18. I do know of one cryptic error.

make a typo in the path to any sound file.

error is something along the lines of invalid file_size(p)

Only clue that it is sound related is in the current_log as the last line will be Loading Sounds.

Re: Dump data.raw to log if there's an error in data stage

Posted: Sat Oct 01, 2016 8:24 pm
by aubergine18
The issue I ran in to was that I did a "find and replace" across files, made a blunder and forgot to commit to github before and after the change, and so I knew exactly what the error message meant, just not where it was happening (because a variable was set wrong in a file and it was only being exposed in a subsequently loaded file). The error message told me *what* was wrong, but not *where* it was wrong.

What might be even more useful than an object dump is to just have a path to the property that's caused the error, for example: "data.raw.storage-tank.stone-well.icon" that would tell me where the error is in a very concise manner.

Re: Dump data.raw to log if there's an error in data stage

Posted: Sat Oct 01, 2016 8:56 pm
by Rseding91
aubergine18 wrote:The issue I ran in to was that I did a "find and replace" across files, made a blunder and forgot to commit to github before and after the change, and so I knew exactly what the error message meant, just not where it was happening (because a variable was set wrong in a file and it was only being exposed in a subsequently loaded file). The error message told me *what* was wrong, but not *where* it was wrong.

What might be even more useful than an object dump is to just have a path to the property that's caused the error, for example: "data.raw.storage-tank.stone-well.icon" that would tell me where the error is in a very concise manner.
The error tells you the type of the prototype, the name of the prototype, and what went wrong. That *is* the path and where the error is coming from.

Re: Dump data.raw to log if there's an error in data stage

Posted: Sat Oct 01, 2016 10:21 pm
by aubergine18
Rseding91 wrote:The error tells you the type of the prototype, the name of the prototype, and what went wrong. That *is* the path and where the error is coming from.
Here's the full error message when an image file is not found:

Code: Select all

-- shown in error dialog:
Error when opening /Users/guyfraser/Library/Application Support/Steam/steamapps/common/Factorio/factorio.app/Contents/data/base/graphics/entity/pipe-covers/pipe-cover-northx.png for reading: No such file or directory

-- shown in log file:
9.395 Error Util.cpp:57: Error when opening /Users/guyfraser/Library/Application Support/Steam/steamapps/common/Factorio/factorio.app/Contents/data/base/graphics/entity/pipe-covers/pipe-cover-northx.png for reading: No such file or directory
From that information, can you tell me the type of prototype, the name of the prototype and the mod that the error occurred in?

Re: Dump data.raw to log if there's an error in data stage

Posted: Sat Oct 01, 2016 10:43 pm
by Rseding91
aubergine18 wrote:
Rseding91 wrote:The error tells you the type of the prototype, the name of the prototype, and what went wrong. That *is* the path and where the error is coming from.
Here's the full error message when an image file is not found:

Code: Select all

-- shown in error dialog:
Error when opening /Users/guyfraser/Library/Application Support/Steam/steamapps/common/Factorio/factorio.app/Contents/data/base/graphics/entity/pipe-covers/pipe-cover-northx.png for reading: No such file or directory

-- shown in log file:
9.395 Error Util.cpp:57: Error when opening /Users/guyfraser/Library/Application Support/Steam/steamapps/common/Factorio/factorio.app/Contents/data/base/graphics/entity/pipe-covers/pipe-cover-northx.png for reading: No such file or directory
From that information, can you tell me the type of prototype, the name of the prototype and the mod that the error occurred in?
If I had the mods yes. Open all .lua files -> search for "pipe-cover-northx.png" and the lua file it's found in is the one causing issues.

When images are loaded what mod they originated from is not known - even by the game itself. The same applies for sounds.

Re: Dump data.raw to log if there's an error in data stage

Posted: Sat Oct 01, 2016 10:59 pm
by Nexela
Rseding91 wrote:The same applies for sounds.
Nix that it is in the log(at least on .13.20. I swear I didn't see it the first time though

Re: Dump data.raw to log if there's an error in data stage

Posted: Sat Oct 01, 2016 11:46 pm
by Rseding91
Nexela wrote:
Rseding91 wrote:The same applies for sounds.
Nix that it is in the log(at least on .13.20. I swear I didn't see it the first time though
The file path sure but which mod is trying to use the sound instance no.

Re: Dump data.raw to log if there's an error in data stage

Posted: Sat Oct 01, 2016 11:55 pm
by Nexela
Rseding91 wrote:
Nexela wrote:
Rseding91 wrote:The same applies for sounds.
Nix that it is in the log(at least on .13.20. I swear I didn't see it the first time though
The file path sure but which mod is trying to use the sound instance no.
Yup but as you said that is enough to find where the user error is.