Thread Tools Display Modes
03/13/14, 08:32 PM   #1
skyraker
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 154
Monitoring for errors

I'm getting tired of having a problem with the addon I'm working where I get an UI error states 'function expected instead of nil'. It doesn't give me any indication on where the error is. I know it typically means I missed some parameter to a function call that was expecting one, but between my last working version and the one with the error I only added function calls that do not take parameters.

Am I missing some way to get a better idea about what the error is about?
  Reply With Quote
03/13/14, 08:51 PM   #2
Xrystal
caritas omnia vincit
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 369
oh I was getting a few of those last beta weekend .. makes it even worse when you only have a few days to write and test addons rofl .. Whenever I got the message it was almost always the last piece of code I added which helped.

I would suggest maybe throwing up the error message you're getting and the block of code that it seems to refer to and go from there.
  Reply With Quote
03/13/14, 10:33 PM   #3
Pawkette
 
Pawkette's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 20
Console can help catch some errors that occur during startup and initialization. Things that the chat window normally wouldn't show.
  Reply With Quote
03/14/14, 03:43 AM   #4
Lyeos
 
Lyeos's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 6
Originally Posted by Pawkette View Post
Console can help catch some errors that occur during startup and initialization. Things that the chat window normally wouldn't show.
Didn't see this one!
I'll test it for sure
  Reply With Quote
03/14/14, 06:04 AM   #5
skyraker
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 154
Originally Posted by Pawkette View Post
Console can help catch some errors that occur during startup and initialization. Things that the chat window normally wouldn't show.
unfortunately, since the error occurs when addons load, Console cannot detect the problem before the game throws its own error.

But thank you.
  Reply With Quote
03/14/14, 06:39 AM   #6
skyraker
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 154
Yay! Figured it out. It is still odd and doesn't make much sense, but has to do with how your add-on is interpreted. For some reason, it would not let me do something early like assign GetFramerate() to a variable, but if I set that variable to 0, then changed it during a function call, it will work.
  Reply With Quote
03/14/14, 10:10 AM   #7
Lodur
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 108
I had a few of them. Mostly when I have a local function that is defined after the first reference...
  Reply With Quote
03/14/14, 12:02 PM   #8
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
You can't reference something before it has been defined.

"Hey did you read that new book by your favorite author?"
"No, I haven't seen it. When did it come out?"
"Next week."
  Reply With Quote
03/15/14, 11:55 PM   #9
Lodur
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 108
Originally Posted by Seerah View Post
You can't reference something before it has been defined.

"Hey did you read that new book by your favorite author?"
"No, I haven't seen it. When did it come out?"
"Next week."

Bah - Just read it twice.

(Cause a 2 pass compiler can handle forward references...)
  Reply With Quote
03/17/14, 06:11 AM   #10
Uesp
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 15
Don't you get a stack trace with the error? All the ones I've seen have a stack trace which gives the exact line the error occurred (at the top of the stack trace).

My usual mistakes when I cause this error are one of two things:
Code:
    val = GetMisSpeled()
The function name is simply misspelled, or:
Code:
     val = GetValue()
     Msg = "Value = " .. val
where the function returns nil and then the string concatentation fails. I've got in the habit of doing:
Code:
    Msg = "Value = ".. tostring(val)
for all strings to avoid this error (nil is turned into the "nil" string).

Another thing I've used successfully in some cases is the pcall() function.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Monitoring for errors


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off