You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Milan Tomic <mi...@setcce.org> on 2004/04/09 14:27:50 UTC

Geting errors

	This is how I pare file:

bool errorsOccured = false;
int errorCount = 0;
try
{
  parser->parse(argv[argc - 1]);
  errorCount = parser->getErrorCount();
  if (errorCount > 0)
    errorsOccured = true;
} catch (const XMLException& e) {
  cerr << "An error occured during parsing\n   Message: "  <<
e.getMessage() << endl;
  errorsOccured = true;
} catch (const DOMException& e) {
  cerr << "A DOM error occured during parsing\n   DOMException code: "
<< e.code << endl;
  errorsOccured = true;
} if (errorsOccured) {
  cout << "Errors during parse" << endl;
  exit (1);
}

	Is there a way to get discription of error if errorsOccured ==
true?

Thank you,
Milan

Re: Geting errors

Posted by Alberto Massari <am...@progress.com>.
At 14.27 09/04/2004 +0200, Milan Tomic wrote:

>         This is how I pare file:
>
>bool errorsOccured = false;
>int errorCount = 0;
>try
>{
>   parser->parse(argv[argc - 1]);
>   errorCount = parser->getErrorCount();
>   if (errorCount > 0)
>     errorsOccured = true;
>} catch (const XMLException& e) {
>   cerr << "An error occured during parsing\n   Message: "  << 
> e.getMessage() << endl;
>   errorsOccured = true;
>} catch (const DOMException& e) {
>   cerr << "A DOM error occured during parsing\n   DOMException code: " << 
> e.code << endl;
>   errorsOccured = true;
>} if (errorsOccured) {
>   cout << "Errors during parse" << endl;
>   exit (1);
>}
>
>         Is there a way to get discription of error if errorsOccured == true?

You need to install an error handler; look at how DOMPrint works

     ...
     DOMCountErrorHandler errorHandler;
     parser->setErrorHandler(&errorHandler);

Alberto


>Thank you,
>Milan



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org