SAXParseException toString - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for SAXParseException toString method.

This code example shows how to use the following methods:getMessage, getLineNumber, getSystemId, toString
      xr.setDTDHandler(null);
      xr.parse(new InputSource(fileReader));
      visitor.close(null);
    } catch (SAXParseException e) {
      System.out.println("XML parsing error: " + "\n" +
          "Line:    " + e.getLineNumber() + "\n" +
          "URI:     " + e.getSystemId() + "\n" +
          "Message: " + e.getMessage());        
      visitor.close(e);
      throw new IOException(e.toString());
    } catch (SAXException e) {
      visitor.close(e);
      throw new IOException(e.toString());
    } catch (RuntimeException e) {
      visitor.close(e);
      throw e;
    } finally { 
      fileReader.close();
    } 
  } 
7
CodeRank
This code example shows how to use the following methods:getMessage, getLineNumber, getSystemId, toString
      xr.setDTDHandler(null);
      xr.parse(new InputSource(fileReader));
      visitor.close(null);
    } catch (SAXParseException e) {
      System.out.println("XML parsing error: " + "\n" +
          "Line:    " + e.getLineNumber() + "\n" +
          "URI:     " + e.getSystemId() + "\n" +
          "Message: " + e.getMessage());        
      visitor.close(e);
      throw new IOException(e.toString());
    } catch (SAXException e) {
      visitor.close(e);
      throw new IOException(e.toString());
    } catch (RuntimeException e) {
      visitor.close(e);
      throw e;
    } finally { 
      fileReader.close();
    } 
  } 
8
CodeRank
This code example shows how to use the following methods:getLineNumber, getSystemId, toString
    public void error(SAXParseException exception) throws SAXException {
        log("Warning", exception);
    } 
 
    private void log(String type, SAXParseException exception) {
        log.warn(type + " parsing the configuration at line " + exception.getLineNumber() + " using system id " + exception.getSystemId() + ": " + exception.toString());
    } 
 
    /** 
     * This method is called when there is a fatal error parsing the configuration file. 
     * The relevant information is written to the log file. 
     */ 
    public void fatalError(SAXParseException exception) throws SAXException {
        log("Fatal error", exception);
        throw exception;
    } 
 
    /** 
     * This method is called when there is a warning parsing the configuration file. 
     * The relevant information is written to the log file. 
6
CodeRank
This code example shows how to use the following methods:getColumnNumber, getLineNumber, toString
     * {@inheritDoc} 
     */ 
    @Override 
    public void error(SAXParseException e) throws SAXException {
        // log exception and carry on... 
        log.error("error encountered at line: " + e.getLineNumber()
                + ", column: " + e.getColumnNumber()
                + " while parsing XML stream: " + e.toString());
    } 
 
    /** 
     * {@inheritDoc} 
     */ 
    @Override 
    public void fatalError(SAXParseException e) throws SAXException {
        // log and re-throw exception 
        log.error("fatal error encountered at line: " + e.getLineNumber()
                + ", column: " + e.getColumnNumber()
                + " while parsing XML stream: " + e.toString());
        throw e;
6
CodeRank
This code example shows how to use the following methods:getMessage, getColumnNumber, getLineNumber, toString
     * 
     * @param   type   message type 
     * @param   err    SAX error 
     */ 
    private void reportException( ReportType type, SAXParseException err ) {
        String msg = err.getMessage();
        if ( msg == null ) {
            msg = err.toString();
        } 
        ReportCode code = AdhocCode.createCodeFromText( type, msg );
        StringBuffer sbuf = new StringBuffer();
        int il = err.getLineNumber();
        int ic = err.getColumnNumber();
        if ( il > 0 ) {
            sbuf.append( " (l." )
                .append( il );
            if ( ic > 0 ) {
                sbuf.append( ", c." )
                    .append( ic );
            } 
6
CodeRank
This code example shows how to use the following methods:getColumnNumber, getLineNumber, toString
    } 
 
    @Override 
    public void error(SAXParseException e) throws SAXException {
        // log exception and carry on... 
        log.error("error encountered at line: " + e.getLineNumber()
                + ", column: " + e.getColumnNumber()
                + " while parsing XML stream: " + e.toString());
    } 
 
    @Override 
    public void fatalError(SAXParseException e) throws SAXException {
        // log and re-throw exception 
        log.error("fatal error encountered at line: " + e.getLineNumber()
                + ", column: " + e.getColumnNumber()
                + " while parsing XML stream: " + e.toString());
        throw e;
    } 
 
    //-------------------------------------------------------< ContentHandler > 
6
CodeRank
This code example shows how to use the following methods:getColumnNumber, getLineNumber, toString
 * assertion failure. 
 */ 
public class JUnitXMLParserErrorHandler implements ErrorHandler{
	 
	private void createErrorMessage(SAXParseException exception){
		Assert.fail("Line number: " + exception.getLineNumber() 
				+ " column: " +	exception.getColumnNumber() 
				+ "\n" 
				+ exception.toString());
	} 
 
	public void error(SAXParseException exception){
		createErrorMessage(exception);
	} 
 
	public void fatalError(SAXParseException exception){
		createErrorMessage(exception);
	} 
 
	public void warning(SAXParseException exception){
6
CodeRank
This code example shows how to use the following methods:getLocalizedMessage, getCause, getMessage, getColumnNumber, getLineNumber
		throw ex;
	} 
 
	@Override 
	public void fatalError(final SAXParseException ex) throws SAXException {
		System.err.println("XML-FATAL: " + getInputSource(ex) + ", line " + ex.getLineNumber() + ", column " + ex.getColumnNumber() + ":");
		System.err.println(ex.toString());
		throw ex;
	} 
 
	@Override 
	public void warning(final SAXParseException ex) throws SAXException {
		System.err.println("XML-WARNING: " + getInputSource(ex) + ", line " + ex.getLineNumber() + ", column " + ex.getColumnNumber() + ":");
		System.err.println(ex.getMessage());
	} 
 
	private String getInputSource(final SAXParseException ex) {
		System.out.println(ex.getPublicId());
		System.out.println(ex.getSystemId());
		System.out.println(ex.getCause());

6
CodeRank
This code example shows how to use the following methods:getColumnNumber, getLineNumber, toString
 
            logger.info("Parsing file " + lexiconPath);
            parser.parse(lexiconPath, senseHandler);
        } catch (SAXParseException spex) {
            logger.error("Problem while parsing entry " + currentKey
                    + ":" + spex.getLineNumber() + ":"
                    + spex.getColumnNumber() + ": " + spex.toString());
        } catch (Exception ex) {
            logger.error("Problem: " + ex);
            ex.printStackTrace();
        } 
    } 
 
    /** 
     * Insert our senses into our SQL table. 
     */ 
    public void insertSense(String lexicon, String lexQuery,
            String id, String n, String level, String shortDef) {
 
        try { 
5
CodeRank
This code example shows how to use the following methods:toString
 
            /* Install a custom error handler. */ 
            messages = new ArrayList();
            parser.setErrorHandler( new ErrorHandler() {
                public void warning( SAXParseException e ) {
                    messages.add( e.toString() );
                } 
                public void error( SAXParseException e ) {
                    messages.add( e.toString() );
                } 
                public void fatalError( SAXParseException e )
                        throws SAXParseException {
                    throw e;
                } 
            } ); 
 
            /* Install a custom content handler. */ 
            namespaces = new HashSet();
            parser.setContentHandler( new DefaultHandler() {
                boolean started;
4
CodeRank
toString Method Overview
Override toString to provide more detailed error message.
See Code Examples for other Java 8 SAXParseException Methods: