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

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

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

Post 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.
Last edited by aubergine18 on Mon Oct 03, 2016 2:03 am, edited 1 time in total.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

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

Post 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.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.
Rseding91
Factorio Staff
Factorio Staff
Posts: 15137
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post 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?
If you want to get ahold of me I'm almost always on Discord.
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

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

Post 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.
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

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

Post 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.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Rseding91
Factorio Staff
Factorio Staff
Posts: 15137
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post 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.
If you want to get ahold of me I'm almost always on Discord.
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

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

Post 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?
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Rseding91
Factorio Staff
Factorio Staff
Posts: 15137
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post 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.
If you want to get ahold of me I'm almost always on Discord.
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

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

Post 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
Rseding91
Factorio Staff
Factorio Staff
Posts: 15137
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post 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.
If you want to get ahold of me I'm almost always on Discord.
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

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

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

Return to “Modding interface requests”