ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   Monitoring for errors (https://www.esoui.com/forums/showthread.php?t=263)

skyraker 03/13/14 08:32 PM

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?

Xrystal 03/13/14 08:51 PM

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.

Pawkette 03/13/14 10:33 PM

Console can help catch some errors that occur during startup and initialization. Things that the chat window normally wouldn't show.

Lyeos 03/14/14 03:43 AM

Quote:

Originally Posted by Pawkette (Post 1205)
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 :)

skyraker 03/14/14 06:04 AM

Quote:

Originally Posted by Pawkette (Post 1205)
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.

skyraker 03/14/14 06:39 AM

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.

Lodur 03/14/14 10:10 AM

I had a few of them. Mostly when I have a local function that is defined after the first reference...

Seerah 03/14/14 12:02 PM

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."

Lodur 03/15/14 11:55 PM

Quote:

Originally Posted by Seerah (Post 1244)
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...)

Uesp 03/17/14 06:11 AM

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.


All times are GMT -6. The time now is 06:42 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI