From ae4cf7c9f0a0b90d02166b43402e67b7d4ad4dca Mon Sep 17 00:00:00 2001 From: Kamal Wickramanayake Date: Sun, 22 Feb 2026 19:31:37 +0530 Subject: Renamed directory 12-error-handling-2 to 11-error-handling-2 --- java/12-error-handling-2/.gitignore | 2 -- java/12-error-handling-2/Maths.java | 11 ---------- java/12-error-handling-2/MathsException.java | 22 ------------------- java/12-error-handling-2/MathsTest.java | 32 --------------------------- java/12-error-handling-2/MathsTest2.java | 27 ----------------------- java/12-error-handling-2/MathsTest3.java | 21 ------------------ java/12-error-handling-2/MathsTest4.java | 33 ---------------------------- java/12-error-handling-2/MathsTest5.java | 21 ------------------ java/12-error-handling-2/MathsTest6.java | 22 ------------------- java/12-error-handling-2/MathsTest7.java | 22 ------------------- 10 files changed, 213 deletions(-) delete mode 100644 java/12-error-handling-2/.gitignore delete mode 100644 java/12-error-handling-2/Maths.java delete mode 100644 java/12-error-handling-2/MathsException.java delete mode 100644 java/12-error-handling-2/MathsTest.java delete mode 100644 java/12-error-handling-2/MathsTest2.java delete mode 100644 java/12-error-handling-2/MathsTest3.java delete mode 100644 java/12-error-handling-2/MathsTest4.java delete mode 100644 java/12-error-handling-2/MathsTest5.java delete mode 100644 java/12-error-handling-2/MathsTest6.java delete mode 100644 java/12-error-handling-2/MathsTest7.java (limited to 'java/12-error-handling-2') diff --git a/java/12-error-handling-2/.gitignore b/java/12-error-handling-2/.gitignore deleted file mode 100644 index e493dd6..0000000 --- a/java/12-error-handling-2/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -bin -dist diff --git a/java/12-error-handling-2/Maths.java b/java/12-error-handling-2/Maths.java deleted file mode 100644 index b61a9f2..0000000 --- a/java/12-error-handling-2/Maths.java +++ /dev/null @@ -1,11 +0,0 @@ -public class Maths { - - public int factorial(int number) throws MathsException { - if (number < 0) { - MathsException e = new MathsException("Factorial of " + number + " not defined"); -// e.setX(100); - throw e; - } - return number == 0 ? 1 : number * factorial(number - 1); - } -} diff --git a/java/12-error-handling-2/MathsException.java b/java/12-error-handling-2/MathsException.java deleted file mode 100644 index bdbaf81..0000000 --- a/java/12-error-handling-2/MathsException.java +++ /dev/null @@ -1,22 +0,0 @@ -public class MathsException extends Exception { - - public MathsException() { - // TODO Auto-generated constructor stub - } - - public MathsException(String message) { - super(message); - // TODO Auto-generated constructor stub - } - - public MathsException(Throwable cause) { - super(cause); - // TODO Auto-generated constructor stub - } - - public MathsException(String message, Throwable cause) { - super(message, cause); - // TODO Auto-generated constructor stub - } - -} diff --git a/java/12-error-handling-2/MathsTest.java b/java/12-error-handling-2/MathsTest.java deleted file mode 100644 index 7b6827c..0000000 --- a/java/12-error-handling-2/MathsTest.java +++ /dev/null @@ -1,32 +0,0 @@ -public class MathsTest { - - /** - * @param args - */ - public static void main(String[] args) { - Maths m = new Maths(); - int result = 0; - - try { - m.factorial(-5); - m.factorial(5); // Not executed - } catch (MathsException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - try { - result = m.factorial(-5); - // ... - } catch(MathsException me) { -// System.err.println(me.getX()); - System.err.println("Factorial method failed"); - } finally { - System.out.println("Inside finally block"); - } - - System.out.println(result); - - } - -} diff --git a/java/12-error-handling-2/MathsTest2.java b/java/12-error-handling-2/MathsTest2.java deleted file mode 100644 index 4aa8b59..0000000 --- a/java/12-error-handling-2/MathsTest2.java +++ /dev/null @@ -1,27 +0,0 @@ -public class MathsTest2 { - - /** - * @param args - */ - public static void main(String[] args) { - Maths m = new Maths(); - int result = 0; - - try { - result = m.factorial(-5); - } catch(MathsException me) { // Catching a specific exception - System.err.println("Caught a MathsException"); - } catch(Exception e) { // Catching the super type - System.err.println("Caught an Exception"); - } - - try { - result = m.factorial(-5); - } catch (MathsException | ArrayIndexOutOfBoundsException e) { // Java SE 7 - - } - - System.out.println(result); - } - -} diff --git a/java/12-error-handling-2/MathsTest3.java b/java/12-error-handling-2/MathsTest3.java deleted file mode 100644 index ca45e5c..0000000 --- a/java/12-error-handling-2/MathsTest3.java +++ /dev/null @@ -1,21 +0,0 @@ -public class MathsTest3 { - - /** - * @param args - */ - public static void main(String[] args) { - Maths m = new Maths(); - int result = 0; - - try { - result = m.factorial(-5); - } catch(MathsException e) { - System.err.println("Factorial method failed"); - System.err.println(e.getMessage()); - e.printStackTrace(); - } - - System.out.println(result); - } - -} diff --git a/java/12-error-handling-2/MathsTest4.java b/java/12-error-handling-2/MathsTest4.java deleted file mode 100644 index b5cca8a..0000000 --- a/java/12-error-handling-2/MathsTest4.java +++ /dev/null @@ -1,33 +0,0 @@ -public class MathsTest4 { - - /** - * @param args - * @throws MathsException - */ - public static void main(String[] args) throws MathsException { - Maths m = new Maths(); - int result = 0; - - // No catching! Then the method should be declared - // to throw the exception (or a super type like - // Exception or even Throwable) - -// m.factorial(5); - - // Look! A try block can be defined without a catch block - // as well. - try { - result = m.factorial(-5); - System.out.println("xxx"); - } finally { - System.out.println("Inside finally block"); - } - - // No try block is also possible - // Since the method is declared to duct the exception - result = m.factorial(-5); - - System.out.println(result); - } - -} diff --git a/java/12-error-handling-2/MathsTest5.java b/java/12-error-handling-2/MathsTest5.java deleted file mode 100644 index 56bf64d..0000000 --- a/java/12-error-handling-2/MathsTest5.java +++ /dev/null @@ -1,21 +0,0 @@ -public class MathsTest5 { - - /** - * @param args - */ - public static void main(String[] args) throws Exception { - Maths m = new Maths(); - int result = 0; - - try { - result = m.factorial(-5); - } catch (MathsException me) { - throw new Exception("My exception wrapper", me); - } finally { - System.out.println("Inside finally block"); - } - - System.out.println(result); - } - -} diff --git a/java/12-error-handling-2/MathsTest6.java b/java/12-error-handling-2/MathsTest6.java deleted file mode 100644 index 7f176aa..0000000 --- a/java/12-error-handling-2/MathsTest6.java +++ /dev/null @@ -1,22 +0,0 @@ -public class MathsTest6 { - - /** - * @param args - */ - public static void main(String[] args) { - Maths m = new Maths(); - int result = 0; - - try { - result = m.factorial(-5); - } catch(MathsException me) { - System.err.println("Factorial method failed"); - System.exit(1); - } finally { - System.out.println("Inside finally block"); - } - - System.out.println(result); - } - -} diff --git a/java/12-error-handling-2/MathsTest7.java b/java/12-error-handling-2/MathsTest7.java deleted file mode 100644 index f55cfad..0000000 --- a/java/12-error-handling-2/MathsTest7.java +++ /dev/null @@ -1,22 +0,0 @@ -public class MathsTest7 { - - /** - * @param args - */ - public static void main(String[] args) { - Maths m = new Maths(); - int result = 0; - - try { - result = m.factorial(-5); - } catch(MathsException me) { - System.err.println("Factorial method failed"); - return; - } finally { - System.out.println("Inside finally block"); - } - - System.out.println(result); - } - -} -- cgit v1.2.3