mirror of
https://github.com/jezhiggins/arabica
synced 2024-11-15 19:48:00 +01:00
Use CatchErrorHandler to report errors
This commit is contained in:
parent
b7d79f2144
commit
78c3ddc505
1 changed files with 13 additions and 3 deletions
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include <string>
|
||||
#include <DOM/SAX2DOM/SAX2DOM.h>
|
||||
#include <SAX/helpers/CatchErrorHandler.h>
|
||||
#include <DOM/Utils/Stream.h>
|
||||
|
||||
////////////////////////////////////////////////
|
||||
|
@ -18,6 +19,8 @@ int main(int argc, char* argv[])
|
|||
|
||||
{ // narrow
|
||||
SAX2DOM::Parser<std::string> domParser;
|
||||
SAX::CatchErrorHandler<std::string> eh;
|
||||
domParser.setErrorHandler(eh);
|
||||
|
||||
for(int i = 1; i < argc; ++i)
|
||||
{
|
||||
|
@ -35,9 +38,16 @@ int main(int argc, char* argv[])
|
|||
domParser.parse(is);
|
||||
} // if(file != "-")
|
||||
|
||||
DOM::Document<std::string> doc = domParser.getDocument();
|
||||
|
||||
std::cout << doc;
|
||||
if(!eh.errorsReported())
|
||||
{
|
||||
DOM::Document<std::string> doc = domParser.getDocument();
|
||||
std::cout << doc;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << eh.errors() << std::endl;
|
||||
eh.reset();
|
||||
} // if ...
|
||||
} // for ...
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue