-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Handle exceptions in coroutine scope dialogs (#25)
- Loading branch information
Showing
4 changed files
with
50 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
test-mod/src/main/kotlin/com/noxcrew/sheeplib/testmod/ExceptionCoroutineDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.noxcrew.sheeplib.testmod | ||
|
||
import com.noxcrew.sheeplib.coroutines.CoroutineScopeDialog | ||
import com.noxcrew.sheeplib.layout.grid | ||
import com.noxcrew.sheeplib.theme.DefaultTheme | ||
import com.noxcrew.sheeplib.theme.Themed | ||
import kotlinx.coroutines.delay | ||
import kotlinx.coroutines.launch | ||
import net.minecraft.client.Minecraft | ||
import net.minecraft.client.gui.components.StringWidget | ||
import net.minecraft.client.gui.layouts.Layout | ||
import net.minecraft.network.chat.Component | ||
import kotlin.time.Duration.Companion.seconds | ||
|
||
/** | ||
* A coroutine scope dialog that throws an exception in a coroutine. | ||
*/ | ||
public class ExceptionCoroutineDialog(x: Int, y: Int) : CoroutineScopeDialog(x, y), Themed by DefaultTheme { | ||
override fun layout(): Layout = grid { | ||
launch { | ||
delay(1.seconds) | ||
error("Test exception from the exception coroutine dialog. This is not a bug.") | ||
} | ||
|
||
StringWidget(Component.literal("This dialog will error shortly"), Minecraft.getInstance().font).atBottom(0) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters