-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathInterpreterException.java
More file actions
72 lines (57 loc) · 1.74 KB
/
InterpreterException.java
File metadata and controls
72 lines (57 loc) · 1.74 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package de.peeeq.wurstio.jassinterpreter;
import de.peeeq.wurstscript.ast.Element;
import de.peeeq.wurstscript.intermediatelang.interpreter.ProgramState;
import de.peeeq.wurstscript.parser.WPos;
public class InterpreterException extends RuntimeException {
private static final long serialVersionUID = 3387292080655779808L;
private Element trace;
private String stackTrace;
public InterpreterException(ProgramState g, String msg) {
super(msg);
this.trace = g.getLastStatement().attrTrace();
}
public InterpreterException(String msg) {
super(msg);
this.trace = null;
}
public InterpreterException(Element trace, String msg) {
super(msg);
this.trace = trace;
}
public InterpreterException(Element trace, String msg, Throwable e) {
super(msg, e);
this.trace = trace;
}
@Override
public String getMessage() {
String res = super.getMessage();
if (trace != null) {
WPos pos = trace.attrSource();
res = res + "\n at " + pos.getFile() + ":" + pos.getLine();
}
return res;
}
@Override
public String toString() {
return getMessage()
+ (stackTrace != null ? "\nStack trace:\n" + stackTrace : "");
}
public InterpreterException setStacktrace(String msg) {
if (this.stackTrace == null) {
this.stackTrace = msg;
}
return this;
}
public InterpreterException setTrace(Element trace) {
if (this.trace == null) {
this.trace = trace;
}
return null;
}
public Element getTrace() {
return trace;
}
public String getWurstStackTrace() {
return stackTrace;
}
}