diff --git a/src/main/kotlin/net/axay/kspigot/runnables/ChainableRunnables.kt b/src/main/kotlin/net/axay/kspigot/runnables/ChainableRunnables.kt index 038bf3ab..5634350c 100644 --- a/src/main/kotlin/net/axay/kspigot/runnables/ChainableRunnables.kt +++ b/src/main/kotlin/net/axay/kspigot/runnables/ChainableRunnables.kt @@ -23,10 +23,10 @@ abstract class ChainedRunnablePart( * any Spigot API functions requires it to be sync) */ inline fun executeCatching( - noinline exceptionHandler: ((E) -> Unit)? = null, - exceptionSync: Boolean = true + exceptionSync: Boolean = true, + noinline exceptionHandler: ((E) -> Unit)? = null ) { - executeCatchingImpl(E::class, exceptionHandler, exceptionSync) + executeCatchingImpl(E::class, exceptionSync, exceptionHandler) } /** @@ -35,8 +35,8 @@ abstract class ChainedRunnablePart( */ abstract fun executeCatchingImpl( exceptionClass: KClass, + exceptionSync: Boolean, exceptionHandler: ((E) -> Unit)?, - exceptionSync: Boolean ) protected fun start(data: T) { @@ -49,8 +49,8 @@ abstract class ChainedRunnablePart( protected fun startCatching( data: T, exceptionClass: KClass, + exceptionSync: Boolean, exceptionHandler: ((E) -> Unit)?, - exceptionSync: Boolean ) { runTask(sync) { val result = try { @@ -68,7 +68,7 @@ abstract class ChainedRunnablePart( return@runTask } else throw e } - next?.startCatching(result, exceptionClass, exceptionHandler, exceptionSync) + next?.startCatching(result, exceptionClass, exceptionSync, exceptionHandler) } } } @@ -82,10 +82,11 @@ class ChainedRunnablePartFirst( = start(Unit) override fun executeCatchingImpl( - exceptionClass: KClass, exceptionHandler: ((E) -> Unit)?, - exceptionSync: Boolean + exceptionClass: KClass, + exceptionSync: Boolean, + exceptionHandler: ((E) -> Unit)? ) = - startCatching(Unit, exceptionClass, exceptionHandler, exceptionSync) + startCatching(Unit, exceptionClass, exceptionSync, exceptionHandler) override fun invoke(data: Unit) = runnable.invoke() @@ -101,10 +102,11 @@ class ChainedRunnablePartThen( = previous.execute() override fun executeCatchingImpl( - exceptionClass: KClass, exceptionHandler: ((E) -> Unit)?, - exceptionSync: Boolean + exceptionClass: KClass, + exceptionSync: Boolean, + exceptionHandler: ((E) -> Unit)? ) = - previous.executeCatchingImpl(exceptionClass, exceptionHandler, exceptionSync) + previous.executeCatchingImpl(exceptionClass, exceptionSync, exceptionHandler) override fun invoke(data: T) = runnable.invoke(data)