Created
August 25, 2015 14:49
-
-
Save RobertFischer/ca2bad03f5e28946ba66 to your computer and use it in GitHub Desktop.
Lambda for the pattern of eating exceptions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ExceptionEater { | |
private static final Logger log = //TODO Create Logger | |
public static <T> T swallowNPE(Supplier<T> producer) { | |
try { | |
return supplier.get(); | |
} catch(NullPointerException npe) { | |
log.info("NullPointerException being swallowed", npe); | |
return null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment