From 27699842f6a4f37c113ef6dac17067c141efdbb0 Mon Sep 17 00:00:00 2001 From: amit2103 Date: Sun, 31 Mar 2019 23:07:34 +0530 Subject: [PATCH] [BAEL-13322] - Removed noexception module : Code already present in libraries module --- noexception/pom.xml | 27 -------- .../noexception/CustomExceptionHandler.java | 24 ------- noexception/src/main/resources/logback.xml | 13 ---- .../noexception/NoExceptionUnitTest.java | 63 ------------------- pom.xml | 2 - 5 files changed, 129 deletions(-) delete mode 100644 noexception/pom.xml delete mode 100644 noexception/src/main/java/com/baeldung/noexception/CustomExceptionHandler.java delete mode 100644 noexception/src/main/resources/logback.xml delete mode 100644 noexception/src/test/java/com/baeldung/noexception/NoExceptionUnitTest.java diff --git a/noexception/pom.xml b/noexception/pom.xml deleted file mode 100644 index f632f1e3a9..0000000000 --- a/noexception/pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - - 4.0.0 - com.baeldung - noexception - 1.0 - noexception - - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - - - - - com.machinezoo.noexception - noexception - ${noexception.version} - - - - - 1.1.0 - - - diff --git a/noexception/src/main/java/com/baeldung/noexception/CustomExceptionHandler.java b/noexception/src/main/java/com/baeldung/noexception/CustomExceptionHandler.java deleted file mode 100644 index 59e13efaa0..0000000000 --- a/noexception/src/main/java/com/baeldung/noexception/CustomExceptionHandler.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.baeldung.noexception; - -import com.machinezoo.noexception.ExceptionHandler; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class CustomExceptionHandler extends ExceptionHandler { - - private Logger logger = LoggerFactory.getLogger(CustomExceptionHandler.class); - - @Override - public boolean handle(Throwable throwable) { - - if (throwable.getClass() - .isAssignableFrom(RuntimeException.class) - || throwable.getClass() - .isAssignableFrom(Error.class)) { - return false; - } else { - logger.error("Caught Exception ", throwable); - return true; - } - } -} diff --git a/noexception/src/main/resources/logback.xml b/noexception/src/main/resources/logback.xml deleted file mode 100644 index 7d900d8ea8..0000000000 --- a/noexception/src/main/resources/logback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/noexception/src/test/java/com/baeldung/noexception/NoExceptionUnitTest.java b/noexception/src/test/java/com/baeldung/noexception/NoExceptionUnitTest.java deleted file mode 100644 index 690ea43520..0000000000 --- a/noexception/src/test/java/com/baeldung/noexception/NoExceptionUnitTest.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.baeldung.noexception; - -import com.machinezoo.noexception.Exceptions; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class NoExceptionUnitTest { - - private static Logger logger = LoggerFactory.getLogger(NoExceptionUnitTest.class); - - @Test - public void whenStdExceptionHandling_thenCatchAndLog() { - try { - System.out.println("Result is " + Integer.parseInt("foobar")); - } catch (Throwable exception) { - logger.error("Caught exception:", exception); - } - } - - @Test - public void whenDefaultNoException_thenCatchAndLog() { - - Exceptions.log().run(() -> System.out.println("Result is " + Integer.parseInt("foobar"))); - } - - @Test - public void givenLogger_whenDefaultNoException_thenCatchAndLogWithClassName() { - System.out.println("Result is " + Exceptions.log(logger).get(() -> +Integer.parseInt("foobar")).orElse(-1)); - } - - @Test - public void givenLoggerAndMessage_whenDefaultNoException_thenCatchAndLogWithClassNameAndMessage() { - System.out.println("Result is " + Exceptions.log(logger, "Something went wrong:").get(() -> +Integer.parseInt("foobar")).orElse(-1)); - } - - @Test - public void givenDefaultValue_whenDefaultNoException_thenCatchAndLogPrintDefault() { - System.out.println("Result is " + Exceptions.log(logger, "Something went wrong:").get(() -> +Integer.parseInt("foobar")).orElse(-1)); - } - - @Test(expected = Error.class) - public void givenCustomHandler_whenError_thenRethrowError() { - CustomExceptionHandler customExceptionHandler = new CustomExceptionHandler(); - customExceptionHandler.run(() -> throwError()); - } - - @Test - public void givenCustomHandler_whenException_thenCatchAndLog() { - CustomExceptionHandler customExceptionHandler = new CustomExceptionHandler(); - customExceptionHandler.run(() -> throwException()); - } - - private static void throwError() { - throw new Error("This is very bad."); - } - - private static void throwException() { - String testString = "foo"; - testString.charAt(5); - } - -} diff --git a/pom.xml b/pom.xml index eaaf90899f..a832d6156f 100644 --- a/pom.xml +++ b/pom.xml @@ -504,7 +504,6 @@ mustache mybatis - noexception optaplanner orika @@ -1149,7 +1148,6 @@ mustache mybatis - noexception optaplanner orika