diff options
Diffstat (limited to 'src/main/java/sevenUnits/unit/LoadingException.java')
-rw-r--r-- | src/main/java/sevenUnits/unit/LoadingException.java | 59 |
1 files changed, 46 insertions, 13 deletions
diff --git a/src/main/java/sevenUnits/unit/LoadingException.java b/src/main/java/sevenUnits/unit/LoadingException.java index 9376ed7..18630a4 100644 --- a/src/main/java/sevenUnits/unit/LoadingException.java +++ b/src/main/java/sevenUnits/unit/LoadingException.java @@ -27,20 +27,29 @@ import java.util.Optional; * @since 2024-08-22 */ public final class LoadingException extends RuntimeException { + /** The type of file that was being loaded. */ public static enum FileType { - UNIT, DIMENSION + @SuppressWarnings("javadoc") UNIT, @SuppressWarnings("javadoc") DIMENSION } - + private static final long serialVersionUID = -8167971828216907607L; - + private final long lineNumber; private final String line; private final Optional<Path> file; - + private final FileType fileType; - + private final RuntimeException problem; - + + /** + * Create a LoadingException from some information, without a file. + * + * @param lineNumber line number error happened on + * @param line text of invalid line + * @param fileType type of file + * @param problem problem, as an Exception + */ public LoadingException(long lineNumber, String line, FileType fileType, RuntimeException problem) { super(problem); @@ -50,7 +59,16 @@ public final class LoadingException extends RuntimeException { this.fileType = fileType; this.problem = problem; } - + + /** + * Create a LoadingException from some information, with a file. + * + * @param lineNumber line number error happened on + * @param line text of invalid line + * @param file file error happened on + * @param fileType type of file + * @param problem problem, as an Exception + */ public LoadingException(long lineNumber, String line, Path file, FileType fileType, RuntimeException problem) { super(problem); @@ -60,15 +78,21 @@ public final class LoadingException extends RuntimeException { this.fileType = fileType; this.problem = problem; } - + + /** + * @return the file this error happened in, if there is one + */ public Optional<Path> file() { return this.file; } - + + /** + * @return type of file that this error happened in + */ public FileType fileType() { return this.fileType; } - + @Override public String getMessage() { return this.file @@ -81,15 +105,24 @@ public final class LoadingException extends RuntimeException { this.lineNumber, this.fileType.toString().toLowerCase(), this.line, this.problem)); } - + + /** + * @return text of line that caused this error + */ public String line() { return this.line; } - + + /** + * @return number of line that caused this error + */ public long lineNumber() { return this.lineNumber; } - + + /** + * @return the error, as an exception + */ public RuntimeException problem() { return this.problem; } |