1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.log4j.spi;
19
20 import java.io.PrintStream;
21
22
23
24
25
26
27
28
29
30 public class ErrorItem {
31
32
33
34 String message;
35
36
37
38 int colNumber = -1;
39
40
41
42 int lineNumber = -1;
43
44
45
46 Throwable exception;
47
48
49
50
51
52
53 public ErrorItem(final String message, final Exception e) {
54 super();
55 this.message = message;
56 exception = e;
57 }
58
59
60
61
62
63 public ErrorItem(final String message) {
64 this(message, null);
65 }
66
67
68
69
70
71 public int getColNumber() {
72 return colNumber;
73 }
74
75
76
77
78
79 public void setColNumber(int colNumber) {
80 this.colNumber = colNumber;
81 }
82
83
84
85
86
87 public Throwable getException() {
88 return exception;
89 }
90
91
92
93
94
95 public void setException(final Throwable exception) {
96 this.exception = exception;
97 }
98
99
100
101
102
103 public int getLineNumber() {
104 return lineNumber;
105 }
106
107
108
109
110
111 public void setLineNumber(final int lineNumber) {
112 this.lineNumber = lineNumber;
113 }
114
115
116
117
118
119 public String getMessage() {
120 return message;
121 }
122
123
124
125
126
127 public void setMessage(final String message) {
128 this.message = message;
129 }
130
131
132
133
134
135 public String toString() {
136 String str =
137 "Reported error: \"" + message + "\"";
138
139 if (lineNumber != -1) {
140 str += " at line " + lineNumber + " column " + colNumber;
141 }
142 if (exception != null) {
143 str += (" with exception " + exception);
144 }
145 return str;
146 }
147
148
149
150
151 public void dump() {
152 dump(System.out);
153 }
154
155
156
157
158
159 public void dump(final PrintStream ps) {
160 String str =
161 "Reported error: \"" + message + "\"";
162
163 if (lineNumber != -1) {
164 str += " at line " + lineNumber + " column " + colNumber;
165 }
166 ps.println(str);
167
168 if (exception != null) {
169 exception.printStackTrace(ps);
170 }
171 }
172 }