blob: 6ba5a7b9c468ef23db2c5f19394cdeb6443f0584 (
plain)
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
|
package com.jantuomi.interpreter.main.exception;
import java.util.HashMap;
import java.util.Map;
/**
* Created by jan on 12.6.2016.
*/
public class InterpreterException {
public enum Exception {
IllegalTokenError,
UnknownOperatorError,
SyntaxError,
TypeError
}
public static Map<Exception, String> errorTexts = new HashMap<>();
static {
errorTexts.put(Exception.IllegalTokenError, "Illegal token %s found.");
errorTexts.put(Exception.UnknownOperatorError, "Unexpected operator %s found.");
errorTexts.put(Exception.SyntaxError, "Unexpected %s.");
errorTexts.put(Exception.TypeError, "Incompatible types %s and %s.");
}
private Exception exception;
public InterpreterException(Exception e) {
exception = e;
}
public String what() {
return errorTexts.get(exception);
}
}
|