From 30d3ce8402015db2a85a4bed35a20bd95bd0c283 Mon Sep 17 00:00:00 2001 From: jantuomi Date: Wed, 3 Aug 2016 09:31:36 +0300 Subject: Add FileNotFoundError, OutOfBoundsError, RecursiveIncludeError Change several GeneralError throws to utilize new error types --- .../exception/types/FileNotFoundTunkkiError.java | 20 ++++++++++++++++++++ .../exception/types/OutOfBoundsTunkkiError.java | 20 ++++++++++++++++++++ .../exception/types/RecursiveIncludeTunkkiError.java | 20 ++++++++++++++++++++ .../jantuomi/tunkki/exception/types/TunkkiError.java | 3 ++- 4 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 src/main/com/jantuomi/tunkki/exception/types/FileNotFoundTunkkiError.java create mode 100644 src/main/com/jantuomi/tunkki/exception/types/OutOfBoundsTunkkiError.java create mode 100644 src/main/com/jantuomi/tunkki/exception/types/RecursiveIncludeTunkkiError.java (limited to 'src/main/com/jantuomi/tunkki/exception') diff --git a/src/main/com/jantuomi/tunkki/exception/types/FileNotFoundTunkkiError.java b/src/main/com/jantuomi/tunkki/exception/types/FileNotFoundTunkkiError.java new file mode 100644 index 0000000..6bd60d6 --- /dev/null +++ b/src/main/com/jantuomi/tunkki/exception/types/FileNotFoundTunkkiError.java @@ -0,0 +1,20 @@ +package com.jantuomi.tunkki.exception.types; + +/** + * Created by jan on 3.8.2016. + */ +public class FileNotFoundTunkkiError extends TunkkiError { + public FileNotFoundTunkkiError(int line, String... args) { + super(line, args); + } + + @Override + public String what() { + return "File %s could not be found."; + } + + @Override + ExceptionType getType() { + return ExceptionType.FileNotFoundError; + } +} diff --git a/src/main/com/jantuomi/tunkki/exception/types/OutOfBoundsTunkkiError.java b/src/main/com/jantuomi/tunkki/exception/types/OutOfBoundsTunkkiError.java new file mode 100644 index 0000000..16c30ae --- /dev/null +++ b/src/main/com/jantuomi/tunkki/exception/types/OutOfBoundsTunkkiError.java @@ -0,0 +1,20 @@ +package com.jantuomi.tunkki.exception.types; + +/** + * Created by jan on 3.8.2016. + */ +public class OutOfBoundsTunkkiError extends TunkkiError { + public OutOfBoundsTunkkiError(int line, String... args) { + super(line, args); + } + + @Override + public String what() { + return "Index %s is out of bounds."; + } + + @Override + ExceptionType getType() { + return ExceptionType.OutOfBoundsError; + } +} diff --git a/src/main/com/jantuomi/tunkki/exception/types/RecursiveIncludeTunkkiError.java b/src/main/com/jantuomi/tunkki/exception/types/RecursiveIncludeTunkkiError.java new file mode 100644 index 0000000..3cb359d --- /dev/null +++ b/src/main/com/jantuomi/tunkki/exception/types/RecursiveIncludeTunkkiError.java @@ -0,0 +1,20 @@ +package com.jantuomi.tunkki.exception.types; + +/** + * Created by jan on 3.8.2016. + */ +public class RecursiveIncludeTunkkiError extends TunkkiError { + public RecursiveIncludeTunkkiError(int line, String... args) { + super(line, args); + } + + @Override + public String what() { + return "Recursive include with module name '%s' detected."; + } + + @Override + ExceptionType getType() { + return ExceptionType.RecursiveIncludeError; + } +} diff --git a/src/main/com/jantuomi/tunkki/exception/types/TunkkiError.java b/src/main/com/jantuomi/tunkki/exception/types/TunkkiError.java index 62c2114..c99e8f9 100644 --- a/src/main/com/jantuomi/tunkki/exception/types/TunkkiError.java +++ b/src/main/com/jantuomi/tunkki/exception/types/TunkkiError.java @@ -22,7 +22,8 @@ abstract public class TunkkiError extends Exception { GeneralError, CastError, DivisionByZeroError, - NadaError + RecursiveIncludeError, + OutOfBoundsError, FileNotFoundError, NadaError } private int line; -- cgit v1.3