diff --git a/libraries/README.md b/libraries/README.md
index 0e58628118..88075af390 100644
--- a/libraries/README.md
+++ b/libraries/README.md
@@ -29,6 +29,8 @@
- [Introduction to Neuroph](http://www.baeldung.com/intro-to-neuroph)
- [Guide to Apache Commons CircularFifoQueue](http://www.baeldung.com/commons-circular-fifo-queue)
- [Quick Guide to RSS with Rome](http://www.baeldung.com/rome-rss)
+- [Introduction to NoException](http://www.baeldung.com/intrduction-to-noexception)
+
The libraries module contains examples related to small libraries that are relatively easy to use and does not require any separate module of its own.
diff --git a/libraries/pom.xml b/libraries/pom.xml
index 8f28a23d75..490302ca29 100644
--- a/libraries/pom.xml
+++ b/libraries/pom.xml
@@ -462,6 +462,11 @@
pcollections
${pcollections.version}
+
+ com.machinezoo.noexception
+ noexception
+ 1.1.0
+
org.eclipse.collections
eclipse-collections
@@ -510,4 +515,4 @@
1.0
8.2.0
-
\ No newline at end of file
+
diff --git a/libraries/src/main/java/com/baeldung/noexception/CustomExceptionHandler.java b/libraries/src/main/java/com/baeldung/noexception/CustomExceptionHandler.java
new file mode 100644
index 0000000000..59e13efaa0
--- /dev/null
+++ b/libraries/src/main/java/com/baeldung/noexception/CustomExceptionHandler.java
@@ -0,0 +1,24 @@
+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/libraries/src/test/java/com/baeldung/noexception/NoExceptionUnitTest.java b/libraries/src/test/java/com/baeldung/noexception/NoExceptionUnitTest.java
new file mode 100644
index 0000000000..b7619202fe
--- /dev/null
+++ b/libraries/src/test/java/com/baeldung/noexception/NoExceptionUnitTest.java
@@ -0,0 +1,62 @@
+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() {
+ Exceptions.log(logger).run(() -> System.out.println("Result is " + Integer.parseInt("foobar")));
+ }
+
+ @Test
+ public void givenLoggerAndMessage_whenDefaultNoException_thenCatchAndLogWithMessage() {
+ Exceptions.log(logger, "Something went wrong:").run(() -> System.out.println("Result is " + Integer.parseInt("foobar")));
+ }
+
+ @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);
+ }
+
+}