Name

The SAXException Class

Synopsis

Most exceptions thrown by SAX methods are instances of the SAXException class or one of its subclasses. The single exception to this rule is the parse( ) method of XMLReader, which may throw a raw IOException if a purely I/O-related error occurs; for example, if a socket is broken before the parser finishes reading the document from the network.

Besides the usual exception methods such as getMessage( ) and printStackTrace( ) that SAXException inherits from or overrides in its superclasses, SAXException adds a getException( ) method to return the nested exception that caused the SAXException to be thrown in the first place.

package org.xml.sax;
     
public class SAXException extends Exception {
     
    public SAXException(String message);
    public SAXException(Exception ex);
    public SAXException(String message, Exception ex);
     
    public String    getMessage(  );
    public Exception getException(  );
    public String    toString(  );
     
}

Get XML in a Nutshell, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.