G'day
I dont seem to be able to get a trycatch block to work.
the code is..
try{
xmlpp:
omParser parser;
parser.set_validate();
parser.parse_file(fileName);
if(parser){
xmlpp::Node *pNode = parser.get_document() ->
get_root_node();
...
}
}catch(const std::exception& ex){
textWindow -> insert(ex.what()); //line 276
}
if I compile this code I receive the following..
file.cxx: In static member function 'static void file:
arseFile(char *):
file.cxx:276: 'ex' undeclared(first use this function)
it does'nt seem reasonable that ex is undeclared here --
doesnt line 275 declare it?
if I commect out line 276 the program compiles and links fine. However it crashes on an improper .xml file.
the output from gdb on the appropriate lines are..
(gdb)n
parser.parsefile(fileName);
(gdb)n
program received signal SIGABRT, Aborted
0xffffe002 in ??()
the code above is basically a cut and paste from an example program from libxml++. the parser should throw some exception. I cant see why a) ex is not seen? and b)given that I comment it out that an exceptionis not caught?
If you have any ideas I would appreciate a response -- I'me very new to c++ but this seems like a standard try/catch block.
thanks in advance.
I dont seem to be able to get a trycatch block to work.
the code is..
try{
xmlpp:
parser.set_validate();
parser.parse_file(fileName);
if(parser){
xmlpp::Node *pNode = parser.get_document() ->
get_root_node();
...
}
}catch(const std::exception& ex){
textWindow -> insert(ex.what()); //line 276
}
if I compile this code I receive the following..
file.cxx: In static member function 'static void file:
file.cxx:276: 'ex' undeclared(first use this function)
it does'nt seem reasonable that ex is undeclared here --
doesnt line 275 declare it?
if I commect out line 276 the program compiles and links fine. However it crashes on an improper .xml file.
the output from gdb on the appropriate lines are..
(gdb)n
parser.parsefile(fileName);
(gdb)n
program received signal SIGABRT, Aborted
0xffffe002 in ??()
the code above is basically a cut and paste from an example program from libxml++. the parser should throw some exception. I cant see why a) ex is not seen? and b)given that I comment it out that an exceptionis not caught?
If you have any ideas I would appreciate a response -- I'me very new to c++ but this seems like a standard try/catch block.
thanks in advance.