Improve error catching in Element.kt
This commit is contained in:
parent
4b80235049
commit
b0e9747fcf
|
@ -12,16 +12,18 @@ abstract class Element(
|
|||
val width: Int, val height: Int
|
||||
): Renderable {
|
||||
companion object Rendering {
|
||||
private var caughtError: Boolean = false
|
||||
@JvmStatic protected val tessellator: Tesselator = Tesselator.getInstance()
|
||||
@JvmStatic protected val buffer: BufferBuilder = tessellator.builder
|
||||
}
|
||||
fun display(stack: PoseStack? = null) {
|
||||
if (!hidden) try {
|
||||
if (!hidden && !caughtError) try {
|
||||
render(stack)
|
||||
} catch (t: Throwable) {
|
||||
with(Snowy.logs) {
|
||||
error("Caught an error when rendering an Element from SnowyGUI:")
|
||||
catching(t)
|
||||
error("An element from snowy threw an error: \n$t")
|
||||
warn("Rendering of snowy UI elements will now be disabled to avoid further errors.")
|
||||
caughtError = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue