diff options
Diffstat (limited to 'main/exception/InterpreterException.java')
| -rw-r--r-- | main/exception/InterpreterException.java | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/main/exception/InterpreterException.java b/main/exception/InterpreterException.java index 8421edc..ac021c0 100644 --- a/main/exception/InterpreterException.java +++ b/main/exception/InterpreterException.java @@ -21,19 +21,20 @@ public class InterpreterException extends Exception { public static Map<ExceptionType, String> errorTexts = new HashMap<>(); static { - errorTexts.put(ExceptionType.IllegalTokenError, "Illegal token %s found."); - errorTexts.put(ExceptionType.UnknownOperatorError, "Unexpected operator %s found."); + errorTexts.put(ExceptionType.IllegalTokenError, "Unknown or illegal token %s found."); errorTexts.put(ExceptionType.SyntaxError, "Unexpected %s."); errorTexts.put(ExceptionType.TypeError, "Incompatible types %s and %s."); - errorTexts.put(ExceptionType.ArgumentError, "Function %s requires %s arguments."); - errorTexts.put(ExceptionType.UndeclaredSymbolError, "No symbol %s defined."); + errorTexts.put(ExceptionType.ArgumentError, "The parameter list given to function %s is either of wrong length or the parameters are of wrong type. Actual: %s"); + errorTexts.put(ExceptionType.UndeclaredSymbolError, "No symbol %s defined, parameters: [%s]."); } private ExceptionType exceptionType; + private String completeMessage; public InterpreterException(ExceptionType exceptionType, int line, String... args) { - super(formatMessage(exceptionType.toString() + ": " + what(exceptionType), line, args), null, false, false); + super(exceptionType.toString(), null, false, false); this.exceptionType = exceptionType; + this.completeMessage = formatMessage(exceptionType.toString() + ": " + what(exceptionType), line, args); } private static String formatMessage(String message, int line, String... args) { @@ -45,4 +46,9 @@ public class InterpreterException extends Exception { public static String what(ExceptionType type) { return errorTexts.get(type); } + + @Override + public void printStackTrace() { + System.err.println(completeMessage); + } } |
