From 0af434b287b7d702ab7fb669c4edccb53ba8e06f Mon Sep 17 00:00:00 2001 From: jantuomi Date: Thu, 28 Jul 2016 14:48:36 +0300 Subject: Handle some error cases --- src/main/com/jantuomi/tunkki/exception/TunkkiError.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/main/com/jantuomi/tunkki/exception') diff --git a/src/main/com/jantuomi/tunkki/exception/TunkkiError.java b/src/main/com/jantuomi/tunkki/exception/TunkkiError.java index b75398a..5de905d 100644 --- a/src/main/com/jantuomi/tunkki/exception/TunkkiError.java +++ b/src/main/com/jantuomi/tunkki/exception/TunkkiError.java @@ -13,19 +13,21 @@ public class TunkkiError extends Exception { IllegalTokenError, SyntaxError, TypeError, - ArgumentError, + FunctionArgumentError, + ExpectedTokenError, UndeclaredSymbolError, IncludeError, GeneralError } - public static Map errorTexts = new HashMap<>(); + private static Map errorTexts = new HashMap<>(); static { 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, "The parameter list given to function %s is either of wrong length or the parameters are of wrong type. Actual: %s"); + errorTexts.put(ExceptionType.ExpectedTokenError, "Token '%s' expects a different token stack."); + errorTexts.put(ExceptionType.FunctionArgumentError, "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]."); errorTexts.put(ExceptionType.IncludeError, "File %s could not be included."); errorTexts.put(ExceptionType.GeneralError, "%s"); @@ -40,9 +42,9 @@ public class TunkkiError extends Exception { this.completeMessage = formatMessage(exceptionType.toString() + ": " + what(exceptionType), line, args); } - private static String formatMessage(String message, int line, String... args) { + private static String formatMessage(String message, int line, String... parameters) { - message = String.format(message, args); + message = String.format(message, parameters); if (line == -1) { return "\n" + message; } else { -- cgit v1.3