aboutsummaryrefslogtreecommitdiffstats
path: root/main/exception/InterpreterException.java
blob: 8129012fd68f21ddd72bf7d5a36b7c920878db6a (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
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 {
        IllegalTokenException,
        UnknownOperatorException
    }

    public static Map<Exception, String> errorTexts = new HashMap<>();

    static {
        errorTexts.put(Exception.IllegalTokenException, "Illegal token %s found.");
        errorTexts.put(Exception.UnknownOperatorException, "Unknown operator %s found.");
    }

    private Exception exception;

    public InterpreterException(Exception e) {
        exception = e;
    }

    public String what() {
        return errorTexts.get(exception);
    }
}