-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathError.java
44 lines (34 loc) · 986 Bytes
/
Error.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package org.bw.tl;
import lombok.Data;
import org.bw.tl.antlr.ast.Node;
import java.io.PrintStream;
public @Data class Error {
private final String message;
private final String file;
private final Node node;
private final ErrorType errorType;
private final int lineNumber;
/**
* Prints the error message to the system error stream
*/
public void print() {
print(System.err);
}
/**
* Print the error message to specified print stream
*
* @param printStream the stream
*/
public void print(final PrintStream printStream) {
printStream.println(this);
}
@Override
public String toString() {
String str = errorType.getName() + ": " + message + System.lineSeparator() +
"\tat " + file + " on line " + lineNumber;
if (node != null) {
str += System.lineSeparator() + "\tat\t\"" + node.getText() + "\"";
}
return str;
}
}