From 0e035aac8bd941c0bcbe266b3019d979cbf0f45e Mon Sep 17 00:00:00 2001 From: Ahmad Date: Sat, 22 Jun 2024 16:56:12 +0200 Subject: [PATCH] Added Exceptions classes --- .../FieldAlreadyDeclaredException.java | 10 ++++++++++ .../LocalVariableAlreadDeclaredException.java | 7 +++++++ .../NotFoundMethodOrConstructor.java | 9 +++++++++ .../NotMatchConstructorException.java | 13 +++++++++++++ .../ParameterAlreadyExistsException.java | 14 ++++++++++++++ .../ExceptionHandler/TypeMismatchException.java | 9 +++++++++ .../VariableNotDeclaredException.java | 13 +++++++++++++ 7 files changed, 75 insertions(+) create mode 100644 src/main/java/de/maishai/typedast/ExceptionHandler/FieldAlreadyDeclaredException.java create mode 100644 src/main/java/de/maishai/typedast/ExceptionHandler/LocalVariableAlreadDeclaredException.java create mode 100644 src/main/java/de/maishai/typedast/ExceptionHandler/NotFoundMethodOrConstructor.java create mode 100644 src/main/java/de/maishai/typedast/ExceptionHandler/NotMatchConstructorException.java create mode 100644 src/main/java/de/maishai/typedast/ExceptionHandler/ParameterAlreadyExistsException.java create mode 100644 src/main/java/de/maishai/typedast/ExceptionHandler/TypeMismatchException.java create mode 100644 src/main/java/de/maishai/typedast/ExceptionHandler/VariableNotDeclaredException.java diff --git a/src/main/java/de/maishai/typedast/ExceptionHandler/FieldAlreadyDeclaredException.java b/src/main/java/de/maishai/typedast/ExceptionHandler/FieldAlreadyDeclaredException.java new file mode 100644 index 0000000..57d4323 --- /dev/null +++ b/src/main/java/de/maishai/typedast/ExceptionHandler/FieldAlreadyDeclaredException.java @@ -0,0 +1,10 @@ +package de.maishai.typedast.ExceptionHandler; + +public class FieldAlreadyDeclaredException extends RuntimeException{ + + public FieldAlreadyDeclaredException(String name) { + super("Field " + name + " already declared"); + } + +} + diff --git a/src/main/java/de/maishai/typedast/ExceptionHandler/LocalVariableAlreadDeclaredException.java b/src/main/java/de/maishai/typedast/ExceptionHandler/LocalVariableAlreadDeclaredException.java new file mode 100644 index 0000000..a11a7ab --- /dev/null +++ b/src/main/java/de/maishai/typedast/ExceptionHandler/LocalVariableAlreadDeclaredException.java @@ -0,0 +1,7 @@ +package de.maishai.typedast.ExceptionHandler; + +public class LocalVariableAlreadDeclaredException extends RuntimeException { + public LocalVariableAlreadDeclaredException(String name){ + super("local Variable " + name + " already declared"); + } +} diff --git a/src/main/java/de/maishai/typedast/ExceptionHandler/NotFoundMethodOrConstructor.java b/src/main/java/de/maishai/typedast/ExceptionHandler/NotFoundMethodOrConstructor.java new file mode 100644 index 0000000..64f69e7 --- /dev/null +++ b/src/main/java/de/maishai/typedast/ExceptionHandler/NotFoundMethodOrConstructor.java @@ -0,0 +1,9 @@ +package de.maishai.typedast.ExceptionHandler; + +public class NotFoundMethodOrConstructor extends RuntimeException { + + public NotFoundMethodOrConstructor() { + super("Method or constructor not found in class"); + } + +} diff --git a/src/main/java/de/maishai/typedast/ExceptionHandler/NotMatchConstructorException.java b/src/main/java/de/maishai/typedast/ExceptionHandler/NotMatchConstructorException.java new file mode 100644 index 0000000..d0474c0 --- /dev/null +++ b/src/main/java/de/maishai/typedast/ExceptionHandler/NotMatchConstructorException.java @@ -0,0 +1,13 @@ +package de.maishai.typedast.ExceptionHandler; + +public class NotMatchConstructorException extends RuntimeException { + + public NotMatchConstructorException(String constructorName) { + super(constructorName); + } + + public NotMatchConstructorException() { + super("Not matching constructor found"); + } + +} diff --git a/src/main/java/de/maishai/typedast/ExceptionHandler/ParameterAlreadyExistsException.java b/src/main/java/de/maishai/typedast/ExceptionHandler/ParameterAlreadyExistsException.java new file mode 100644 index 0000000..4d9a6d8 --- /dev/null +++ b/src/main/java/de/maishai/typedast/ExceptionHandler/ParameterAlreadyExistsException.java @@ -0,0 +1,14 @@ +package de.maishai.typedast.ExceptionHandler; + +public class ParameterAlreadyExistsException extends RuntimeException{ + public ParameterAlreadyExistsException(String paraName) { + super("Parameter '" + paraName + "' already exists"); + } + public ParameterAlreadyExistsException(String paraName, String methodOrConstructorName) { + super("Parameter '" + paraName + "' already exists in " + methodOrConstructorName); + } + public ParameterAlreadyExistsException() { + super("Parameter already exists"); + } + +} \ No newline at end of file diff --git a/src/main/java/de/maishai/typedast/ExceptionHandler/TypeMismatchException.java b/src/main/java/de/maishai/typedast/ExceptionHandler/TypeMismatchException.java new file mode 100644 index 0000000..30b7c05 --- /dev/null +++ b/src/main/java/de/maishai/typedast/ExceptionHandler/TypeMismatchException.java @@ -0,0 +1,9 @@ +package de.maishai.typedast.ExceptionHandler; + +public class TypeMismatchException extends RuntimeException{ + + public TypeMismatchException(String operator) { + super("Type mismatch in operator: " + operator); + } + +} \ No newline at end of file diff --git a/src/main/java/de/maishai/typedast/ExceptionHandler/VariableNotDeclaredException.java b/src/main/java/de/maishai/typedast/ExceptionHandler/VariableNotDeclaredException.java new file mode 100644 index 0000000..741e4ef --- /dev/null +++ b/src/main/java/de/maishai/typedast/ExceptionHandler/VariableNotDeclaredException.java @@ -0,0 +1,13 @@ +package de.maishai.typedast.ExceptionHandler; + +public class VariableNotDeclaredException extends RuntimeException{ + + public VariableNotDeclaredException(String variableName) { + super("Variable '" + variableName + "' not declared"); + } + public VariableNotDeclaredException(String variableName, String methodName) { + super("Variable '" + variableName + "' not declared in method '" + methodName + "'"); + } + + +}