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>
This commit is contained in:
committed by
maibin
parent
accb430f5e
commit
69d8c10751
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user