How to solve WML errors
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
How to solve WML errors
Does you campaign produce obscure WML errors on startup and you don't know what line in your 2000 lines of WML causes it? Instead of going through everything line by line and try to spot the mistake you've made, or before posting your entire campaign on the forums in the hopes that someone wants to do it for you, try this instead:
Safety precautions: backup your campaign. Not necessary if you really trust the undo capabilities of your editor.
1. Remove half or more of the WML of your campaign. For example, remove every scenario other than the first one.
2. Test if you still get errors.
3. If you still got the error, then you know the error is in the parts that are still remaining. Go back to step 2 and again remove as much as you easily can (for example, cut away all the [event]s of that scenario you have left). Repeat until you've isolated the bug to a small enough section that you can easily just go through it line by line.
4. If you didn't get the error anymore, then you know you've just removed the part containing the error. Restore it, and then go to step 2 and apply that procedure to that part only. Repeat until you've isolated the bug to a small enough section that you can easily just go through it line by line.
This is a surprisingly quick and easy method of debugging obscure errors the source of which you can't really locate based on the error message. Mostly useful for campaigns, since they can contain large amounts of WML, but can just as well be used in debugging of single MP scenarios, for example. If you still cannot find what's wrong, then of course you can ask here on the forums, but you should still try to isolate the problem as well as you can beforehand to make helping you easier for others (it's not fun to dig through a 1000 lines of unfamiliar WML, if the one asking for help could have easily just trimmed that down to 200 lines first).
Of course, the easiest way of debugging is still to always test your stuff after making changes, so you will spot bugs as you make them and don't need to hunt for them later on.
EDIT
renamed thread title to "How to solve WML errors"
Safety precautions: backup your campaign. Not necessary if you really trust the undo capabilities of your editor.
1. Remove half or more of the WML of your campaign. For example, remove every scenario other than the first one.
2. Test if you still get errors.
3. If you still got the error, then you know the error is in the parts that are still remaining. Go back to step 2 and again remove as much as you easily can (for example, cut away all the [event]s of that scenario you have left). Repeat until you've isolated the bug to a small enough section that you can easily just go through it line by line.
4. If you didn't get the error anymore, then you know you've just removed the part containing the error. Restore it, and then go to step 2 and apply that procedure to that part only. Repeat until you've isolated the bug to a small enough section that you can easily just go through it line by line.
This is a surprisingly quick and easy method of debugging obscure errors the source of which you can't really locate based on the error message. Mostly useful for campaigns, since they can contain large amounts of WML, but can just as well be used in debugging of single MP scenarios, for example. If you still cannot find what's wrong, then of course you can ask here on the forums, but you should still try to isolate the problem as well as you can beforehand to make helping you easier for others (it's not fun to dig through a 1000 lines of unfamiliar WML, if the one asking for help could have easily just trimmed that down to 200 lines first).
Of course, the easiest way of debugging is still to always test your stuff after making changes, so you will spot bugs as you make them and don't need to hunt for them later on.
EDIT
renamed thread title to "How to solve WML errors"
Last edited by zookeeper on November 13th, 2007, 2:15 pm, edited 1 time in total.
-
- Posts: 15
- Joined: June 7th, 2007, 11:44 am
i think there is another good way
i think when people have .cfg-files with more than 1500 lines (my case), you should copy the lines where you think there is the bug (might be the lines you added last). then you test this lines in another scenario. it's another way. i just wanted to say this.
aka mysticspiral
something that I've noticed
well, a little something that I noticed is that if you're using Wesnoth (1.2. and Windows notepad as the editor (me). Then when you get the error message, it usually tells you the tag that is either still open, or improperly closed. If you read the message a little more then it tells you a general line number. In some cases, it tells you the exact line that is still open/closed. In others it just tells you the basic group that its in, like it'll say "...line 2455..." and the only tag there is like message or something. Well, what it really means it that the problem is somewhere between whatever tag is open at 'line 2455' and its closing tag. Now the only problem is locating it.
If you're looking for a certain line, and using Windows notepad, then this is solved easily. Just go to 'View' and make sure 'Status Bar' is selected. At the bottom of notepad will be a status bar that tells you what line you're on and even what character you're on.
Now if you have the more difficult problem of having to find where it is between that set of code, then all you really have to do is look.
There's my simple way of solving some of the WML problems I run in to. Hope it helps some of you.
If you're looking for a certain line, and using Windows notepad, then this is solved easily. Just go to 'View' and make sure 'Status Bar' is selected. At the bottom of notepad will be a status bar that tells you what line you're on and even what character you're on.
Now if you have the more difficult problem of having to find where it is between that set of code, then all you really have to do is look.
There's my simple way of solving some of the WML problems I run in to. Hope it helps some of you.
Re: How to easily debug WML
So this was the sticky you meant. Sorry, zookeeper and all!zookeeper wrote:Does you campaign produce obscure WML errors on startup and you don't know what line in your 2000 lines of WML causes it? Instead of going through everything line by line and try to spot the mistake you've made, or before posting your entire campaign on the forums in the hopes that someone wants to do it for you, try this instead:
Safety precautions: backup your campaign. Not necessary if you really trust the undo capabilities of your editor.
1. Remove half or more of the WML of your campaign. For example, remove every scenario other than the first one.
2. Test if you still get errors.
3. If you still got the error, then you know the error is in the parts that are still remaining. Go back to step 2 and again remove as much as you easily can (for example, cut away all the [event]s of that scenario you have left). Repeat until you've isolated the bug to a small enough section that you can easily just go through it line by line.
4. If you didn't get the error anymore, then you know you've just removed the part containing the error. Restore it, and then go to step 2 and apply that procedure to that part only. Repeat until you've isolated the bug to a small enough section that you can easily just go through it line by line.
This is a surprisingly quick and easy method of debugging obscure errors the source of which you can't really locate based on the error message. Mostly useful for campaigns, since they can contain large amounts of WML, but can just as well be used in debugging of single MP scenarios, for example. If you still cannot find what's wrong, then of course you can ask here on the forums, but you should still try to isolate the problem as well as you can beforehand to make helping you easier for others (it's not fun to dig through a 1000 lines of unfamiliar WML, if the one asking for help could have easily just trimmed that down to 200 lines first).
Of course, the easiest way of debugging is still to always test your stuff after making changes, so you will spot bugs as you make them and don't need to hunt for them later on.
He who is still learning WML, can still make a campaign. (or at least try)
You are an Arch Mage - You're definitely intelligent, but some people would say you spend too much time inside. The power you have learned, however, is simply unmatched.
You are an Arch Mage - You're definitely intelligent, but some people would say you spend too much time inside. The power you have learned, however, is simply unmatched.
Re: How to easily debug WML
For the record, it is a lot easier to spot missing quote strings and missing end tags if you use a text editor with Syntax Highlighting or if you run Wesnoth's wmllint or wmliterator.py (a Maintenance tool distributed with the game).
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
- solsword
- Code Contributor
- Posts: 291
- Joined: January 12th, 2009, 10:21 pm
- Location: Santa Cruz, CA
- Contact:
Re: How to easily debug WML
Something that seems to be cropping up a lot recently:
The game will crash with an error message about a missing closing tag. The line number will be randomly somewhere in the middle of your scenario. There won't be anything wrong on that line, and the tag named in the error will be properly closed.
In this case, make sure you look at the full error output from Wesnoth. Most of the time, the error that is displayed in-game is the last of a series of errors, all of which are printed to the standard error output. If you fix these errors starting with the first one displayed, the later errors, including the "missing closing tag" error, are likely to vanish, as they may have been caused by the earlier errors.
To view the full error output:
On Windows: when you run the game and it crashes, it should create a file called "stderr.txt". Look here for the output.
Other operating systems: Launch the game from a terminal, and the error output will be displayed in the terminal.
Please correct me if I'm wrong about the above, as I couldn't find anything about this on the Wiki, and I don't have a Windows box.
The game will crash with an error message about a missing closing tag. The line number will be randomly somewhere in the middle of your scenario. There won't be anything wrong on that line, and the tag named in the error will be properly closed.
In this case, make sure you look at the full error output from Wesnoth. Most of the time, the error that is displayed in-game is the last of a series of errors, all of which are printed to the standard error output. If you fix these errors starting with the first one displayed, the later errors, including the "missing closing tag" error, are likely to vanish, as they may have been caused by the earlier errors.
To view the full error output:
On Windows: when you run the game and it crashes, it should create a file called "stderr.txt". Look here for the output.
Other operating systems: Launch the game from a terminal, and the error output will be displayed in the terminal.
Please correct me if I'm wrong about the above, as I couldn't find anything about this on the Wiki, and I don't have a Windows box.
The Knights of the Silver Spire campaign.
http://www.cs.hmc.edu/~pmawhorter - my website.
Teamcolors for everyone! PM me for a teamcolored version of your sprite, or you can do it yourself. If you just happen to like magenta, no hard feelings?
http://www.cs.hmc.edu/~pmawhorter - my website.
Teamcolors for everyone! PM me for a teamcolored version of your sprite, or you can do it yourself. If you just happen to like magenta, no hard feelings?
-
- Posts: 637
- Joined: December 20th, 2009, 5:59 pm
- Location: Germany
Re: How to easily debug WML
Another way to delete large texts is this:
Of course, you mustn't use {comment}.
Edit: you can also use a '#ifdef XXX' but there's a small chance that others made a macro called 'XXX' even if it's sometimes used in the mainline.
Code: Select all
#define comment
-[i]wrong text[/i]
#enddef
Edit: you can also use a '#ifdef XXX' but there's a small chance that others made a macro called 'XXX' even if it's sometimes used in the mainline.
- SpoOkyMagician
- Posts: 281
- Joined: September 5th, 2008, 8:04 am
- Location: I have no idea...
Re: How to easily debug WML
personally, I find the "stderr.txt" the easiest/best way to debug WML errors. There shouldn't be any need to remove half the code and whatnot as suggested above. Unless, you are VERY NEW to WML or have MAJOR WML ERRORS... (Just make sure you follow the error output in order. Top first then go down. The errors under may be caused by the first error. Example: Sometimes you get errors such as; "missing closing tag multiplayer". If you did close the tag, ignore the error.)
edit: The only other exception that could cause problems can be duplicated id's or many different add-ons conflicting with one another. In this case, cut/paste your add-on's onto your desktop and put one addon in at a time. Attempt to figure out which add-on is causing the problem. (if stderr.txt is no help to you.)
Note that if wesnoth does not show an error during the loading process, that DOES NOT mean that there are still possible errors. Give the scenario/campaign/etc a test run and look though the stderr.txt afterwords. (DO NOT RESTART WESNOTH AFTER THE TEST OR YOU WILL LOSE ALL THE RESULTS.) The possible runtime WML errors will be shown in the log. (if any) Check what could be causing the problem and make your changes. Test run once again. (Repeat until all errors are gone/undetectable.)
Wesnoth 1.6.5 note (windows) Ignore this error:
This is the way I debug WML. I DO NOT TOLERATE any WML bugs in my stderr.txt or I do not release them unless they are only minor. (But, this is just the way i debug. You can ignore the runtime errors if you wish but, it will only lead to future problems if/when WML is updated...)
edit: Always check the reference wiki if you are unsure about any attributes/tags/etc related errors. (http://wiki.wesnoth.org/ReferenceWML) Just note that some attributes/tags/etc can be outdated or not available depending on which version of wesnoth you are using.
edit: If you find any WML errors related to downloaded add-on's, feel free to contact the author or post a reply in their topic of the add-on. Please make sure that you are very clear on what the problem is and copy/paste related stderr.txt error messages. If you are experienced with WML, also explain to them what is causing the problem just in case they are new to WML as well. (If you are 100% sure what is causing the problem.)
edit: The only other exception that could cause problems can be duplicated id's or many different add-ons conflicting with one another. In this case, cut/paste your add-on's onto your desktop and put one addon in at a time. Attempt to figure out which add-on is causing the problem. (if stderr.txt is no help to you.)
Note that if wesnoth does not show an error during the loading process, that DOES NOT mean that there are still possible errors. Give the scenario/campaign/etc a test run and look though the stderr.txt afterwords. (DO NOT RESTART WESNOTH AFTER THE TEST OR YOU WILL LOSE ALL THE RESULTS.) The possible runtime WML errors will be shown in the log. (if any) Check what could be causing the problem and make your changes. Test run once again. (Repeat until all errors are gone/undetectable.)
Wesnoth 1.6.5 note (windows) Ignore this error:
I believe this is just a 1.6.5/windows related bug. I didn't notice this error in 1.7.15 with windows. (It will continually generate the line above so ignore those lines.)20100327 23:27:32 error filesystem: Could not open 'C:/Users/<USERNAME>/Documents/My Games/Wesnoth1.6/editor/maps/' for reading.
This is the way I debug WML. I DO NOT TOLERATE any WML bugs in my stderr.txt or I do not release them unless they are only minor. (But, this is just the way i debug. You can ignore the runtime errors if you wish but, it will only lead to future problems if/when WML is updated...)
edit: Always check the reference wiki if you are unsure about any attributes/tags/etc related errors. (http://wiki.wesnoth.org/ReferenceWML) Just note that some attributes/tags/etc can be outdated or not available depending on which version of wesnoth you are using.
edit: If you find any WML errors related to downloaded add-on's, feel free to contact the author or post a reply in their topic of the add-on. Please make sure that you are very clear on what the problem is and copy/paste related stderr.txt error messages. If you are experienced with WML, also explain to them what is causing the problem just in case they are new to WML as well. (If you are 100% sure what is causing the problem.)
"You don't have to understand me, I'm just there!" ~ SpoOkyMagician
Creator of: Unwelcome Guests Series, Modifiable Android Project, SpoOky's Survivals, and many more... (Most of my old stuff is gone.)
(User Page)
Creator of: Unwelcome Guests Series, Modifiable Android Project, SpoOky's Survivals, and many more... (Most of my old stuff is gone.)
(User Page)
-
- Posts: 637
- Joined: December 20th, 2009, 5:59 pm
- Location: Germany
Re: How to easily debug WML
There are errors not listed in stderr.txt. These errors are, if your code haven't got mistakes but it just don't work like you'd like to have and you don't know why.
Re: How to easily debug WML
This is NOT thread necroing, since this thread is a sticky
As a few people have mentioned above, cutting out half your scenario code isn't completely necessary, and can sometimes cause the scenario to not run at all (if you have to take out crucial events). Perhaps a footnote on how to debug errors themselves? Here are some notes I found useful from writing campaigns:
As a few people have mentioned above, cutting out half your scenario code isn't completely necessary, and can sometimes cause the scenario to not run at all (if you have to take out crucial events). Perhaps a footnote on how to debug errors themselves? Here are some notes I found useful from writing campaigns:
Campaign Debugging
Last edited by bigkahuna on October 15th, 2010, 3:45 pm, edited 3 times in total.
Re: How to easily debug WML
Personally, I've never debugged that way. The in-game error logs always work fine. (Surely if you use 1.9, all the bugs and error will be highlighted 1 by 1)
Formerly known as the creator of Era of Chaos and maintainer of The Aragwaithi and the Era of Myths.
Re: How to easily debug WML
I'm using 1.8... you have an in-game error log?!?!? WITH HIGHLIGHT?!?
I'm jealous.
All the good add-ons are still on 1.8, though, except for the few ported over by the over-achievers.
I'm jealous.
All the good add-ons are still on 1.8, though, except for the few ported over by the over-achievers.
Re: How to easily debug WML
Just the same system as 1.8, only it shows every single things that causes errors or won't work.bigkahuna wrote:I'm using 1.8... you have an in-game error log?!?!? WITH HIGHLIGHT?!?
I'm jealous.
All the good add-ons are still on 1.8, though, except for the few ported over by the over-achievers.
Formerly known as the creator of Era of Chaos and maintainer of The Aragwaithi and the Era of Myths.