/* -*-             c-basic-offset: 4; indent-tabs-mode: nil; -*-  //------100-columns-wide------>|*/
// for license please see accompanying LICENSE.txt file (available also at http://www.xmlpull.org/)

package org.jboss.modules.xml;

/**
 * This exception is thrown to signal XML Pull Parser related faults.
 *
 * @author <a href="http://www.extreme.indiana.edu/~aslom/">Aleksander Slominski</a>
 */
public class XmlPullParserException extends Exception {
    protected Throwable detail;
    protected int row = -1;
    protected int column = -1;

    /*    public XmlPullParserException() {
          }*/

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

    /*
    public XmlPullParserException(String s, Throwable thrwble) {
        super(s);
        this.detail = thrwble;
        }

    public XmlPullParserException(String s, int row, int column) {
        super(s);
        this.row = row;
        this.column = column;
    }
    */

    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;
    }

    /*
    public String getMessage() {
        if(detail == null)
            return super.getMessage();
        else
            return super.getMessage() + "; nested exception is: \n\t"
                + detail.getMessage();
    }
    */

    //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();
            }
        }
    }

}


@@ -459,33 +459,75 @@
   pr
-otected Throwable detail;
+ivate static final long serialVersionUID = - 8715154876633542268L;%0A
 %0A   
@@ -587,67 +587,8 @@
 1;%0A%0A
-    /*    public XmlPullParserException() %7B%0A          %7D*/%0A%0A
     
@@ -658,293 +658,8 @@
  %7D%0A%0A
-    /*%0A    public XmlPullParserException(String s, Throwable thrwble) %7B%0A        super(s);%0A        this.detail = thrwble;%0A        %7D%0A%0A    public XmlPullParserException(String s, int row, int column) %7B%0A        super(s);%0A        this.row = row;%0A        this.column = column;%0A    %7D%0A    */%0A%0A
     
@@ -935,16 +935,23 @@
 %22+chain)
+, chain
 );%0A%0A    
@@ -1093,103 +1093,10 @@
     
-    this.detail = chain;%0A    %7D%0A%0A    public Throwable getDetail() %7B%0A        return detail;%0A    
 %7D
+%0A
 %0A   
@@ -1293,631 +1293,7 @@
   %7D%0A
-%0A    /*%0A    public String getMessage() %7B%0A        if(detail == null)%0A            return super.getMessage();%0A        else%0A            return super.getMessage() + %22; nested exception is: %5Cn%5Ct%22%0A                + detail.getMessage();%0A    %7D%0A    */%0A%0A    //NOTE: code that prints this and detail is difficult in J2ME%0A    public void printStackTrace() %7B%0A        if (detail == null) %7B%0A            super.printStackTrace();%0A        %7D else %7B%0A            synchronized(System.err) %7B%0A                System.err.println(super.getMessage() + %22; nested exception is:%22);%0A                detail.printStackTrace();%0A            %7D%0A        %7D%0A    %7D%0A%0A
 %7D%0A%0A

Improve exception reporting