Skip to content

Commit 28e4687

Browse files
committed
Better syntax for exceptions
1 parent 4fc904b commit 28e4687

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

interfaces/src/main/kotlin/com/noxcrew/interfaces/view/AbstractInterfaceView.kt

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import com.noxcrew.interfaces.InterfacesListeners.Companion.REOPEN_REASONS
77
import com.noxcrew.interfaces.element.CompletedElement
88
import com.noxcrew.interfaces.event.DrawPaneEvent
99
import com.noxcrew.interfaces.exception.InterfacesExceptionContext
10+
import com.noxcrew.interfaces.exception.InterfacesExceptionHandler
1011
import com.noxcrew.interfaces.exception.InterfacesExceptionResolution
1112
import com.noxcrew.interfaces.exception.InterfacesOperation
1213
import com.noxcrew.interfaces.grid.GridPoint
@@ -59,7 +60,7 @@ public abstract class AbstractInterfaceView<I : InterfacesInventory, T : Interfa
5960
/** The interface backing this view. */
6061
public val backing: T,
6162
birthParent: InterfaceView?,
62-
) : InterfaceView {
63+
) : InterfaceView, InterfacesExceptionHandler by backing.builder.exceptionHandler {
6364

6465
public companion object {
6566
/** The amount of columns a chest inventory has. */
@@ -778,18 +779,4 @@ public abstract class AbstractInterfaceView<I : InterfacesInventory, T : Interfa
778779
override fun runChatQuery(timeout: Duration, onCancel: suspend () -> Unit, onComplete: suspend (Component) -> Boolean) {
779780
InterfacesListeners.INSTANCE.startChatQuery(this, timeout, onCancel, onComplete)
780781
}
781-
782-
/** Executes [function], reporting any errors to the [InterfacesExceptionHandler] being used. */
783-
public suspend fun <T> execute(
784-
context: InterfacesExceptionContext,
785-
onException: suspend (Exception, InterfacesExceptionResolution) -> Unit = { _, _ -> },
786-
function: suspend () -> T,
787-
): T? = builder.exceptionHandler.execute(context.copy(view = this), onException, function)
788-
789-
/** Executes [function], reporting any errors to the [InterfacesExceptionHandler] being used. */
790-
public fun <T> executeSync(
791-
context: InterfacesExceptionContext,
792-
onException: (Exception, InterfacesExceptionResolution) -> Unit = { _, _ -> },
793-
function: () -> T,
794-
): T? = builder.exceptionHandler.executeSync(context.copy(view = this), onException, function)
795782
}

0 commit comments

Comments
 (0)