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
54 public ErrorItem(final String message, final Exception e) {
55 super();
56 this.message = message;
57 exception = e;
58 }
59
60
61
62
63
64
65 public ErrorItem(final String message) {
66 this(message, null);
67 }
68
69
70
71
72
73
74 public int getColNumber() {
75 return colNumber;
76 }
77
78
79
80
81
82
83 public void setColNumber(int colNumber) {
84 this.colNumber = colNumber;
85 }
86
87
88
89
90
91
92 public Throwable getException() {
93 return exception;
94 }
95
96
97
98
99
100
101 public void setException(final Throwable exception) {
102 this.exception = exception;
103 }
104
105
106
107
108
109
110 public int getLineNumber() {
111 return lineNumber;
112 }
113
114
115
116
117
118
119 public void setLineNumber(final int lineNumber) {
120 this.lineNumber = lineNumber;
121 }
122
123
124
125
126
127
128 public String getMessage() {
129 return message;
130 }
131
132
133
134
135
136
137 public void setMessage(final String message) {
138 this.message = message;
139 }
140
141
142
143
144
145
146 public String toString() {
147 String str =
148 "Reported error: \"" + message + "\"";
149
150 if (lineNumber != -1) {
151 str += " at line " + lineNumber + " column " + colNumber;
152 }
153 if (exception != null) {
154 str += (" with exception " + exception);
155 }
156 return str;
157 }
158
159
160
161
162 public void dump() {
163 dump(System.out);
164 }
165
166
167
168
169
170
171 public void dump(final PrintStream ps) {
172 String str =
173 "Reported error: \"" + message + "\"";
174
175 if (lineNumber != -1) {
176 str += " at line " + lineNumber + " column " + colNumber;
177 }
178 ps.println(str);
179
180 if (exception != null) {
181 exception.printStackTrace(ps);
182 }
183 }
184 }