Krimm's Guide
to World of Warcraft Addon Design

Appendix 1
Debugging


There is much that can go astray when working with AddOns.  Unfortunately the error messages provided by WoW aren’t always helpful.  Here are a few tips to troubleshooting AddOns:

- Watch out for version changes.  Remember that the .toc file has the expected version of WoW at the top.  This must match the actual version of WoW for your AddOn to load.  Be sure that when WoW upgrades, you adjust the version number in your .toc file.  Here’s an article on getting the version number:  http://www.wowwiki.com/HOWTO:_Get_Current_Interface_Number
Simpler is to find the version number from another AddOn’s .toc file.  Also, you can just ask in the forums on this site.

- Check your names carefully.  Case matters.  Underscores matter.  The names “MyAddOn”, “MyAddon”, and “My_AddOn” are all different.

- Watch out for smart quotations.  Many editors and word processors (such as Microsoft Word) like to replace normal quotation marks with “smart quotes”.  In virtually all cases, you’ll want normal quotation marks.  These tend to be displayed as two parallel lines running straight up and down, while smart quotes tend to be angled and sometimes curved.

- Make sure there are no spaces after “.xml” in your .toc files.  If there are, WoW will consider the spaces to be part of the file name.  This will cause WoW to fail to find the XML file, preventing your AddOn from running. 

- Make sure to initialize all variables with safe default values.  Even if you expect to normally use a saved value, you can’t count on it.  The first time your AddOn runs, there won’t be anything saved.  And the user could always have deleted the saved variables file.  Safe defaults eliminate a whole category of tricky bugs.

- Write lots of comments.  If your code isn’t working, you’ll often find that improving the comments causes you to realize what is wrong.  But looking at this the other way, don’t assume just because a comment says your code does something, that the code actually does it.  Sometimes you’ll find that what your comments say happens and what really happens are entirely different things.

- Keep your XML and Lua separate.  If you’re having problems and you’ve let Lua creep into your XML, try cleaning things up.  You may run across the source of the problem in the process.

- Watch out for old “saved variable” values.  If you already have a saved variable value stored for your AddOn and you change assumptions about that data, or if a buggy version of your AddOn stored bad data, you can run into trouble.  You can remove these by hand (see the sections in this guide on saved variables for details on where these values are stored). 

- As with many programming languages, the line number reported in an error message isn’t necessarily the line containing the actual error.

- If you can’t figure it out, ask.  The many different WoW forums are great sources of information.  You’ll often find helpful people willing to answer your questions.  If you’re not sure where to ask, the forums on wow.tentonhammer.com are a great place to start. 


Go to Appendix 2 - Links and Credits!


To read the latest guides, news, and features you can visit our World of Warcraft Game Page.

Last Updated: Mar 13, 2016

Comments

Related Content

Patch 5.4 Profession Changes