@Override public void writeSuccess() { Try.run(success::invoke) .onFailure(cause -> log.error("Error while invoking success callback", cause)); }
@Override public void run() { if (watcher != null) { log.debug("stopping: watcher"); Try.run(watcher::stop).onFailure(ex -> log.debug("Stop of watcher resulted in error", ex)); } commands.forEach(cmd -> { log.debug("stopping: " + cmd); Try.run(cmd::stop).onFailure(ex -> log.error("Stop of " + cmd + " resulted in error", ex)); }); } }
protected void fireCloseEvent() { Throwing.Runnable task = onclose.getAndSet(null); if (task != null) { Try.run(task).onFailure(ex -> log.error("close callback resulted in error", ex)); } }
public void close() throws Exception { reporters.forEach(r -> Try.run(r::close) .onFailure(cause -> log.error("close of {} resulted in error", r, cause))); }
private static void fireStop(final Jooby app, final Logger log, final List<Throwing.Consumer<Registry>> onStop) { // stop services onStop.forEach(c -> Try.run(() -> c.accept(app)) .onFailure(x -> log.error("shutdown of {} resulted in error", c, x))); }
public static void forceConverter(final AsyncRepository repo, final JacksonMapper converter) { Try.run(() -> FIELD.apply(repo.getClass()).set(repo, converter)) .onFailure(x -> log.warn("Set converter resulted in error", x)); } }
@Override public void writeFailed(final Throwable cause) { Try.run(() -> err.onError(cause)) .onFailure(ex -> log.error("Error while invoking err callback", ex)); } };
public void done(final Optional<Throwable> cause) { if (complete.size() > 0) { for (Route.Complete h : complete) { Try.run(() -> h.handle(req, this, cause)) .onFailure(x -> LoggerFactory.getLogger(Response.class) .error("complete listener resulted in error", x)); } complete.clear(); } end(); }
@Override protected void closeInternal() { Try.run(() -> rsp.closeOutput()) .onFailure(cause -> log.debug("error while closing connection", cause)); }
static Handler tryPage(final Handler handler, final Logger log) { return (req, rsp, ex) -> Try.run(() -> handler.handle(req, rsp, ex)).onFailure(cause -> log.debug("execution of pretty err page resulted in exception", cause)); }
@SuppressWarnings({"rawtypes", "unchecked"}) private <T> T configure(final T source, final Config config) { List<Method> methods = Lists.newArrayList(source.getClass().getMethods()); config.entrySet().forEach(o -> { String key = o.getKey(); String setter = "set" + CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, key); Object raw = o.getValue().unwrapped(); Optional<Method> result = methods.stream() .filter(m -> m.getName().equals(setter)) .findFirst(); if (result.isPresent()) { Method method = result.get(); Class type = method.getParameterTypes()[0]; Object value = cast(type, raw); Try.run(() -> method.invoke(source, value)).onFailure(ex -> { throw new IllegalArgumentException("Bad option: <" + raw + "> for: " + method, ex); }); } else { log.error("Unknown option camel.{} = {}", key, raw); } }); return source; }
.onFailure(x -> log.error("can't copy {}", it, x));
aggregators.accept(a); a.fileset().forEach(f -> values.add(spath(f))); })).onFailure(x -> values.add(it))); raw.put(key.get(0), values); graph.put(key.get(0), key);
services.forEach(exec -> Try.run(() -> exec.getValue().shutdown()).onFailure(cause -> log.error("shutdown of {} resulted in error", exec.getKey(), cause))); services.clear(); });
public void end() { try { if (rollbackOnly) { rollback(); } else { commit(); } } finally { if (readOnly) { setConnectionReadOnly(false); } String sessionId = oid(session); log.debug("closing session: {}", sessionId); Try.run(session::close) .onFailure(x -> log.error("session.close() resulted in exception: {}", sessionId, x)) .onSuccess(() -> log.debug("session closed: {}", sessionId)); unbind(session.getSessionFactory()); } }
.onFailure(x -> { log.debug("png-fallback resulted in exception", x); callback.call(null, toV8Array(v8, Arrays.asList(x.getMessage())));
@Override default void handle(final Request req, final Response rsp, final Chain chain) throws Throwable { Sse sse = req.require(Sse.class); String path = req.path(); rsp.send(new Deferred(deferred -> { try { sse.handshake(req, () -> { Try.run(() -> handle(req, sse)) .onSuccess(() -> deferred.resolve(null)) .onFailure(ex -> { deferred.reject(ex); Logger log = LoggerFactory.getLogger(Sse.class); log.error("execution of {} resulted in error", path, ex); }); }); } catch (Exception ex) { deferred.reject(ex); } })); }
log.debug("Stopping {}", cstr); Try.run(session::close) .onFailure(x -> log.error("session.close() resulted in exception", x));