package net.pterodactylus.util.exception /** * Runs the given [runnable][Runnable], catching any [exceptions][Exception], * and running the [errorRunnable][Runnable] with a caught exception. * * @param runnable The block to run * @param errorRunnable The block to run in case of an exception */ fun suppressException(runnable: () -> Unit = {}, errorRunnable: (e: Exception) -> Unit = {}): () -> Unit = { try { runnable() } catch (e: Exception) { errorRunnable(e) } }