Exception handling



Hello.

I'm using xmlpp on my project to parse some xmls. I'm using TextReader.
The problem is that I cannot handle an exception:

I have my bugged xml file, described:


<Spawns>

    <Spawn begin="12:01" chance="10">
   
        <Creature id="1"/>
       
    </Spawn>


Note that there isn't a </Spawns> closing it.
I run my program, described (I tried to catch all possible exceptions):


int main()
{
    try
    {
        TextReader reader("Test.xml");
        while(reader.read())
        {

        }
    }
    catch (const std::exception& e)
    {
        cout << "Exception caught: " << e.what() << endl;
    }
    catch (const xmlpp::exception& e)
    {
        cout << "Exception caught: " << e.what() << endl;
    }
    catch (const xmlpp::parse_error& e)
    {
        cout << "Exception caught: " << e.what() << endl;
    }
    catch (const xmlpp::validity_error& e)
    {
        cout << "Exception caught: " << e.what() << endl;
    }

    return 0;
}


It does not catch any exception, and on my console, I get the following message:

Test.xml:9: parser error :  Extra content at the end of the document

What can I do to handle all exceptions?

Thanks,

Lucas.




USE O MESSENGER DENTRO DO HOTMAIL SEM PRECISAR INSTALAR NADA. CLIQUE PARA VER COMO.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]