blob: b4b4b7135888eae05c1cb509bf3c6d0605c25531 [file] [log] [blame]
The Android Open Source Projectadc854b2009-03-03 19:28:47 -08001/* -*- 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
4package org.xmlpull.v1;
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 */
11public class XmlPullParserException extends Exception {
12 protected Throwable detail;
13 protected int row = -1;
14 protected int column = -1;
15
16 /* public XmlPullParserException() {
17 }*/
18
19 public XmlPullParserException(String s) {
20 super(s);
21 }
22
23 /*
24 public XmlPullParserException(String s, Throwable thrwble) {
25 super(s);
26 this.detail = thrwble;
27 }
28
29 public XmlPullParserException(String s, int row, int column) {
30 super(s);
31 this.row = row;
32 this.column = column;
33 }
34 */
35
36 public XmlPullParserException(String msg, XmlPullParser parser, Throwable chain) {
37 super ((msg == null ? "" : msg+" ")
38 + (parser == null ? "" : "(position:"+parser.getPositionDescription()+") ")
39 + (chain == null ? "" : "caused by: "+chain));
40
41 if (parser != null) {
42 this.row = parser.getLineNumber();
43 this.column = parser.getColumnNumber();
44 }
45 this.detail = chain;
46 }
47
48 public Throwable getDetail() { return detail; }
49 // public void setDetail(Throwable cause) { this.detail = cause; }
50 public int getLineNumber() { return row; }
51 public int getColumnNumber() { return column; }
52
53 /*
54 public String getMessage() {
55 if(detail == null)
56 return super.getMessage();
57 else
58 return super.getMessage() + "; nested exception is: \n\t"
59 + detail.getMessage();
60 }
61 */
62
63 //NOTE: code that prints this and detail is difficult in J2ME
64 public void printStackTrace() {
65 if (detail == null) {
66 super.printStackTrace();
67 } else {
68 synchronized(System.err) {
69 System.err.println(super.getMessage() + "; nested exception is:");
70 detail.printStackTrace();
71 }
72 }
73 }
74
75}
76