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
12 extends Exception
13 {
14 /**
15 * @deprecated use generic getCause() method
16 */
17 @Deprecated
18 protected Throwable detail;
19
20 protected int row = -1;
21
22 protected int column = -1;
23
24 /*
25 * public XmlPullParserException() { }
26 */
27
28 public XmlPullParserException( String s )
29 {
30 super( s );
31 }
32
33 /*
34 * public XmlPullParserException(String s, Throwable throwable) { super(s); this.detail = throwable; } public
35 * XmlPullParserException(String s, int row, int column) { super(s); this.row = row; this.column = column; }
36 */
37
38 public XmlPullParserException( String msg, XmlPullParser parser, Throwable chain )
39 {
40 super( ( msg == null ? "" : msg + " " )
41 + ( parser == null ? "" : "(position:" + parser.getPositionDescription() + ") " )
42 + ( chain == null ? "" : "caused by: " + chain ), chain );
43
44 if ( parser != null )
45 {
46 this.row = parser.getLineNumber();
47 this.column = parser.getColumnNumber();
48 }
49 this.detail = chain;
50 }
51
52 /**
53 * @deprecated Use the generic <code>getCause()</code> method
54 * @return the cause
55 */
56 @Deprecated
57 public Throwable getDetail()
58 {
59 return getCause();
60 }
61
62 // public void setDetail(Throwable cause) { this.detail = cause; }
63 public int getLineNumber()
64 {
65 return row;
66 }
67
68 public int getColumnNumber()
69 {
70 return column;
71 }
72
73 /*
74 * public String getMessage() { if(detail == null) return super.getMessage(); else return super.getMessage() +
75 * "; nested exception is: \n\t" + detail.getMessage(); }
76 */
77
78 // NOTE: code that prints this and detail is difficult in J2ME
79 @Override
80 public void printStackTrace()
81 {
82 if ( getCause() == null )
83 {
84 super.printStackTrace();
85 }
86 else
87 {
88 synchronized ( System.err )
89 {
90 System.err.println( super.getMessage() + "; nested exception is:" );
91 getCause().printStackTrace();
92 }
93 }
94 }
95
96 }