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 Kuznetsov Dmitriy <dk...@garant.ru> on 2004/07/13 13:29:11 UTC

parser does not thow fatal error

  Hi All!
  
  I'm trying to parse not existing file, but 'parse' method
  does not emit any exception... Simplified code is:

  XercesDOMParser* parser = new XercesDOMParser;

  try {
    parser->parse ("");
  } catch (...) {
    printf ("error");  // never reached!
  }


  Debugger said that:

  1. IGXMLScanner::scanDocument turn on flag 'fInException' & call emitError
  2. XMLScanner::emitError check that 'fErrorReporter' is false & call
     'emitErrorWillThrowException':

     bool XMLScanner::emitErrorWillThrowException(const XMLErrs::Codes toEmit)
     {

       // in my case:
       //  - XMLErrs::isFatal(toEmit) return true
       //  - 'fExitOnFirstFatal' is set to true
       //  - BUT 'fInException' was set to true on step 1 & this
       //    method return false. So XMLScanner::emitError doesn't
       //    emit fatal exception

       if (XMLErrs::isFatal(toEmit) && fExitOnFirstFatal && !fInException)
         return true;
       return false;
     }



  Can anybody explain to me is it possible to force
  XercesDOMParser::parse throw fatal exception
  in such cases?  


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


Re[2]: parser does not thow fatal error

Posted by Kuznetsov Dmitriy <dk...@garant.ru>.
> Note that
> the catch block's after the parser->parse don't catch this.  However, if
> you modify the DOMTreeErrorReporter::fatalError routine to throw the
> exception (instead of just handling it) then you will get into the
> catch(...) block after parser->parse.

 Thank you very much!


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


Re: parser does not thow fatal error

Posted by David Cargill <ca...@ca.ibm.com>.



Hi,
You need to set an ErrorHandler so that errors can be returned to you.  If
you modify the DOMPrint to do a parser->parse("")  you will get a
FatalError message (which is caught in DOMTreeErrorReporter).  Note that
the catch block's after the parser->parse don't catch this.  However, if
you modify the DOMTreeErrorReporter::fatalError routine to throw the
exception (instead of just handling it) then you will get into the
catch(...) block after parser->parse.

Regards,
David A. Cargill
XML Parser Development
IBM Toronto Lab


                                                                           
             Kuznetsov Dmitriy                                             
             <dk...@garant.ru>                                               
                                                                        To 
             07/13/2004 07:29          xerces-c-dev@xml.apache.org         
             AM                                                         cc 
                                                                           
                                                                   Subject 
             Please respond to         parser does not thow fatal error    
               xerces-c-dev                                                
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




  Hi All!

  I'm trying to parse not existing file, but 'parse' method
  does not emit any exception... Simplified code is:

  XercesDOMParser* parser = new XercesDOMParser;

  try {
    parser->parse ("");
  } catch (...) {
    printf ("error");  // never reached!
  }


  Debugger said that:

  1. IGXMLScanner::scanDocument turn on flag 'fInException' & call
emitError
  2. XMLScanner::emitError check that 'fErrorReporter' is false & call
     'emitErrorWillThrowException':

     bool XMLScanner::emitErrorWillThrowException(const XMLErrs::Codes
toEmit)
     {

       // in my case:
       //  - XMLErrs::isFatal(toEmit) return true
       //  - 'fExitOnFirstFatal' is set to true
       //  - BUT 'fInException' was set to true on step 1 & this
       //    method return false. So XMLScanner::emitError doesn't
       //    emit fatal exception

       if (XMLErrs::isFatal(toEmit) && fExitOnFirstFatal && !fInException)
         return true;
       return false;
     }



  Can anybody explain to me is it possible to force
  XercesDOMParser::parse throw fatal exception
  in such cases?


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




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