Our Helpful Error Reporter!

Thalassicus

Bytes and Nibblers
Joined
Nov 9, 2005
Messages
11,057
Location
Texas
The lua error reports are so incredibly helpful! :crazyeye:

Runtime Error: [string "D:\Thalassicus\Documents\My Games\Sid Meier..."]:369: attempt to call field '?' (a nil value)
Runtime Error: [string "D:\Thalassicus\Documents\My Games\Sid Meier..."]:95: attempt to index field '?' (a nil value)
Runtime Error: [string "D:\Thalassicus\Documents\My Games\Sid Meier..."]:231: attempt to call a nil value

What are the file names? The field names? It knows but just doesn't want to say! I've spent over an hour tonight just trying to figure out where these are in a project of 300+ files. :hammer2:
 
There was a brief period when they'd actually fixed it to drop the path from the error message, but then a more recent SDK update changed it back to the old way. Given that Civ5's default directory is inside your My Documents/My Games/Sid Meier's Civilization V/ directory, there's not a whole lot of room left for the actual filename.

The only way I deal with this is that every Lua function I use has a print statement at its start and its end, and when I'm debugging something I just turn all of those on. So if you see "SpatzStartCombat start" without a "SpatzStartCombat end" in FireTuner, then you know the error was inside the SpatzStartCombat function.
 
Same approach here...print statements are the only way to track things. I just place one print statement in the begining with FUNCTION: Blah triggered.

This way I can step through things easily.

If all else fails, I painfully check line 369, 95 and 231 in each file, starting with the most recently changed ones.

Of course with 300+ files, my advise might be weak!
 
Yep, we need a text editor with a search feature that can show on screen the line X of a multitude of files... Or simply ask firaxis to fix that (again).
 
If all else fails, I painfully check line 369, 95 and 231 in each file, starting with the most recently changed ones.

The problem is, any function with an "include" will often have the numbers wrong, because it'll effectively insert the included file in that spot. So the line numbers given might be hundreds away from whatever's actually giving the error.

It's very annoying. For my most common offendors, I not only have "start" and "end" print statements at the appropriate spots, I also have a few additional print statements scattered throughout (giving things like loop indices, so that you can figure out which player/unit/city it crashed on), and I'll just comment out those prints when I'm ready to post the files. It shouldn't be this hard, really, but I've had to deal with worse in the past.
 
It's very annoying. For my most common offendors, I not only have "start" and "end" print statements at the appropriate spots, I also have a few additional print statements scattered throughout (giving things like loop indices, so that you can figure out which player/unit/city it crashed on), and I'll just comment out those prints when I'm ready to post the files. It shouldn't be this hard, really, but I've had to deal with worse in the past.

Gedemon's code uses a 'Dprint' function which allows you to turn on or off print lines across the whole code or specific sections. Save removing lines post release and useful for troubleshoot other players issues with your mod.

Just mentioning it incase you are not aware of it.
 
I use a lua logger similar to log4j. It's got the enable/disable capability, and I like using integrated string.format codes in my print statements. What I'm most looking forward to is the capability to use debug.traceback. It won't work for lua's standard error messages, but at least we will be able to do manual tracebacks ourselves.
 
Back
Top Bottom