Pazyryk
Deity
- Joined
- Jun 13, 2008
- Messages
- 3,584
Edit 12 Jan 2013: Problem identified (post #20) and workaround found (post # 23). Or see my Tutorial/Reference here:
How to restore Runtime Error reports for your Lua code
I've produced about 4 bugs in the last day. All of them very mundane stuff: trying to do arithmetic on a nil, accidentally calling pairs(nil), and so forth. They are not being reported in the Fire Tuner or Lua.log. The function just crashes silently. In all cases, I have tracked the error the hard way (print statements and commenting out blocks) and eventually found a common garden variety bug in my code.
I've seen this with either EnableLuaDebugLibrary = 1 or 0. Some bugs are reported. Others not. It's consistent in that the same "pairs(nil)" bug was unreported through the 2 hours I spent tracking it down. But then when I added the same error in a function and called it from Fire Tuner, the error was reported correctly. And errors I type in the command line cause an error statement. Am I going insane? Anyone else seen this or have any ideas?
Edit: No, I'm not insane. Just found another one (Player instead of Players and a missing text field):
Fire tuner just prints:
EaMain: check1
EaMain: check2
EaMain: check3
EaMain: -------- New turn for playerID 2 --------
No error statement printed after "check3".
But if I paste that line into the command line (with "test" for text), it reports a Runtime Error.
How to restore Runtime Error reports for your Lua code
I've produced about 4 bugs in the last day. All of them very mundane stuff: trying to do arithmetic on a nil, accidentally calling pairs(nil), and so forth. They are not being reported in the Fire Tuner or Lua.log. The function just crashes silently. In all cases, I have tracked the error the hard way (print statements and commenting out blocks) and eventually found a common garden variety bug in my code.
I've seen this with either EnableLuaDebugLibrary = 1 or 0. Some bugs are reported. Others not. It's consistent in that the same "pairs(nil)" bug was unreported through the 2 hours I spent tracking it down. But then when I added the same error in a function and called it from Fire Tuner, the error was reported correctly. And errors I type in the command line cause an error statement. Am I going insane? Anyone else seen this or have any ideas?
Edit: No, I'm not insane. Just found another one (Player instead of Players and a missing text field):
Code:
print("check3")
--print messege to UI:
local text = "Travelers tell of a faraway civilization called " .. Locale.ConvertTextKey(eaPlayer.tkEaCiv) .. "..."
Player[Game.GetActivePlayer()]:AddNotification(NotificationTypes.NOTIFICATION_GENERIC, text, -1, -1)
print(text)
EaMain: check1
EaMain: check2
EaMain: check3
EaMain: -------- New turn for playerID 2 --------
No error statement printed after "check3".
But if I paste that line into the command line (with "test" for text), it reports a Runtime Error.