View Javadoc
1   /* -*-             c-basic-offset: 4; indent-tabs-mode: nil; -*-  //------100-columns-wide------>|*/
2   // for license please see accompanying LICENSE.txt file (available also at http://www.xmlpull.org/)
3   
4   package org.codehaus.plexus.util.xml.pull;
5   
6   /**
7    * This exception is thrown to signal XML Pull Parser related faults.
8    *
9    * @author <a href="http://www.extreme.indiana.edu/~aslom/">Aleksander Slominski</a>
10   */
11  public class XmlPullParserException extends Exception {
12      /**
13       * @deprecated use generic getCause() method
14       */
15      @Deprecated
16      protected Throwable detail;
17  
18      protected int row = -1;
19  
20      protected int column = -1;
21  
22      /*
23       * public XmlPullParserException() { }
24       */
25  
26      public XmlPullParserException(String s) {
27          super(s);
28      }
29  
30      /*
31       * public XmlPullParserException(String s, Throwable throwable) { super(s); this.detail = throwable; } public
32       * XmlPullParserException(String s, int row, int column) { super(s); this.row = row; this.column = column; }
33       */
34  
35      public XmlPullParserException(String msg, XmlPullParser parser, Throwable chain) {
36          super(
37                  (msg == null ? "" : msg + " ")
38                          + (parser == null ? "" : "(position:" + parser.getPositionDescription() + ") ")
39                          + (chain == null ? "" : "caused by: " + chain),
40                  chain);
41  
42          if (parser != null) {
43              this.row = parser.getLineNumber();
44              this.column = parser.getColumnNumber();
45          }
46          this.detail = chain;
47      }
48  
49      /**
50       * @deprecated Use the generic <code>getCause()</code> method
51       * @return the cause
52       */
53      @Deprecated
54      public Throwable getDetail() {
55          return getCause();
56      }
57  
58      // public void setDetail(Throwable cause) { this.detail = cause; }
59      public int getLineNumber() {
60          return row;
61      }
62  
63      public int getColumnNumber() {
64          return column;
65      }
66  
67      /*
68       * public String getMessage() { if(detail == null) return super.getMessage(); else return super.getMessage() +
69       * "; nested exception is: \n\t" + detail.getMessage(); }
70       */
71  
72      // NOTE: code that prints this and detail is difficult in J2ME
73      @Override
74      public void printStackTrace() {
75          if (getCause() == null) {
76              super.printStackTrace();
77          } else {
78              synchronized (System.err) {
79                  System.err.println(super.getMessage() + "; nested exception is:");
80                  getCause().printStackTrace();
81              }
82          }
83      }
84  }