diff options
Diffstat (limited to 'main/exception/InterpreterException.java')
| -rw-r--r-- | main/exception/InterpreterException.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/main/exception/InterpreterException.java b/main/exception/InterpreterException.java new file mode 100644 index 0000000..8129012 --- /dev/null +++ b/main/exception/InterpreterException.java @@ -0,0 +1,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); + } +} |
