/** * Executes an {@link Action}, catching any error. * * @param action to be executed */ public static void doSafe(Action action) { action.executeSafe(); }
/** * Performs this actionl. If any error occurs, it will be merely logged. */ default void executeSafe() { try { this.execute(); } catch (Throwable t) { LoggerFactory.getLogger(Action.class).error("Execution failed.", t); } } }