Eric Goebelbecker 69d8c10751 BAEL-1044 - Introduction to NoException (#2412)
* BAEL-1044 - Introduction to NoException

* BAEL-1044 - Introduction to NoException

* BAEL-1044 - Introduction to NoException

* BAEL-1044 - Introduction to NoException

* BAEL-1044 - Introduction to NoException

* Update pom.xml

Add missing </dependency>
2017-08-10 10:59:38 -07:00

25 lines
674 B
Java

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;
}
}
}