@Test public void swallowRuntimeException() { final String result = Exceptions.swallow(() -> methodThatThrowsRuntimeException(), DEFAULT_RESULT); assertEquals(result, DEFAULT_RESULT); }
public static <T> T swallow(final Supplier<T> supplier, final T defaultReturn) { try { return supplier.get(); } catch (Exception e) { LOGGER.debug("Exception swallowed", e.getMessage()); return defaultReturn; } }
Exceptions { public static <T> T swallow(final Supplier<T> supplier, final T defaultReturn) { try { return supplier.get(); } catch (Exception e) { LOGGER.debug("Exception swallowed", e.getMessage()); return defaultReturn; } } }
Exceptions { public static <T> T swallow(final Supplier<T> supplier, final T defaultReturn) { try { return supplier.get(); } catch (Exception e) { LOGGER.debug("Exception swallowed", e.getMessage()); return defaultReturn; } }  }
Exceptions { public static <T> T swallow(final Supplier<T> supplier, final T defaultReturn) { try { return supplier.get(); } catch (Exception e) { LOGGER.debug("Exception swallowed", e.getMessage()); return defaultReturn; } }  static T swallow(final Supplier<T> supplier, final T defaultReturn); }
Exceptions { public static <T> T swallow(final Supplier<T> supplier, final T defaultReturn) { try { return supplier.get(); } catch (Exception e) { LOGGER.debug("Exception swallowed", e.getMessage()); return defaultReturn; } }  static T swallow(final Supplier<T> supplier, final T defaultReturn);  }