aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/com/jantuomi/tunkki/exception
diff options
context:
space:
mode:
authorjantuomi <jans.tuomi@gmail.com>2016-07-28 14:48:36 +0300
committerjantuomi <jans.tuomi@gmail.com>2016-07-28 14:48:36 +0300
commit0af434b287b7d702ab7fb669c4edccb53ba8e06f (patch)
treea661f64a0a0054c0bdfd1327f2a5fee9e3f15ab8 /src/main/com/jantuomi/tunkki/exception
parent33fde43199c0b9874d362ee13c8b752e7174527d (diff)
Handle some error cases
Diffstat (limited to 'src/main/com/jantuomi/tunkki/exception')
-rw-r--r--src/main/com/jantuomi/tunkki/exception/TunkkiError.java12
1 files changed, 7 insertions, 5 deletions
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<ExceptionType, String> errorTexts = new HashMap<>();
+ private static Map<ExceptionType, String> 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 {