When CHAT_MSG_MONEY fires, before UpdateFigures is called, auditorLastMoney is set to 0 if it's nil. But for PLAYER_MONEY, it's not checked.
Leads me to believe that this error's cropped up before and was fixed in one execution path but not another.
Anyway, auditorLastMoney is set to the current money at AceEvent_FullyInitialized -- which may very well be after a PLAYER_MONEY event. I'd say that's the cause -- either that, or something else could be messing with it, since auditorLastMoney is defined globally (why?).
I'd suggest throwing this in at the very top of Auditor.lua:
Thanks, Nymbia. I don't know what you mean by the execution path thing, though - what's that? auditorLastMoney is defined globally because Auditor is split into two parts - the bit that does all the money checking, and the FuBar plugin that shows all the results. However, you're right, that variable is only used in one... so my bad for not defining it locally.
Thanks for your help, and I will see if the error pops up again, but no one has reported it before and that code hasn't changed since I released it in October last year. Weird! Thankies :)
Edit: I've just moved the event registrations, other than for AceEvent_FullyInitialized, to be called when it is fully initialised. That should fix that too, I think.
Admittedly, I don't see how that error would pop up in any but the rarest of circumstances, the only direct example that I can think of is a money change before AceEvent_FullyInitialized (looted by a group member while you're reloading or something).. and the OP said it happened consistently.
["message"] = "invalid key to 'next'"
["stack"] = "[C]: ?[C]:
in function `(for generator)'...ce\\AddOns\\BigWigs\\Libs\\AceEvent-2.0\\AceEvent-2.0.lua:1226:
in function <...ce\\AddOns\\BigWigs\\Libs\\AceEvent-2.0\\AceEvent-2.0.lua:1215>