All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.xmlpull.v1.XmlPullParserException Maven / Gradle / Ivy


/*
 * XMLPULL API IS FREE
 * -------------------
 *
 * All of the XMLPULL API source code, compiled code, and documentation
 * contained in this distribution *except* for tests (see separate LICENSE_TESTS.txt)
 * are in the Public Domain.
 *
 * XMLPULL API comes with NO WARRANTY or guarantee of fitness for any purpose.
 *
 * Initial authors:
 *
 * Stefan Haustein
 * Aleksander Slominski
 *
 * 2001-12-12
 */

package org.xmlpull.v1;

/**
 * This exception is thrown to signal XML Pull Parser related faults.
 *
 * @author Aleksander Slominski
 */
public class XmlPullParserException extends Exception {
    protected Throwable detail;
    protected int row = -1;
    protected int column = -1;

    public XmlPullParserException(String s) {
        super(s);
    }

    public XmlPullParserException(String msg, XmlPullParser parser, Throwable chain) {
        super ((msg == null ? "" : msg+" ")
               + (parser == null ? "" : "(position:"+parser.getPositionDescription()+") ")
               + (chain == null ? "" : "caused by: "+chain));

        if (parser != null) {
            this.row = parser.getLineNumber();
            this.column = parser.getColumnNumber();
        }
        this.detail = chain;
    }

    public Throwable getDetail() { return detail; }
    //    public void setDetail(Throwable cause) { this.detail = cause; }
    public int getLineNumber() { return row; }
    public int getColumnNumber() { return column; }


    //NOTE: code that prints this and detail is difficult in J2ME
    public void printStackTrace() {
        if (detail == null) {
            super.printStackTrace();
        } else {
            synchronized(System.err) {
                System.err.println(super.getMessage() + "; nested exception is:");
                detail.printStackTrace();
            }
        }
    }

}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy