Skip to content

Commit

Permalink
fix: readd error message to DataFetcher
Browse files Browse the repository at this point in the history
  • Loading branch information
My-Name-Is-Jeff committed Dec 17, 2023
1 parent 99cc178 commit 6e3a2ac
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/main/kotlin/gg/skytils/skytilsmod/core/DataFetcher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import kotlinx.serialization.Serializable
import kotlinx.serialization.json.*
import net.minecraft.util.BlockPos
import kotlin.concurrent.fixedRateTimer
import kotlin.reflect.jvm.jvmName

object DataFetcher {
private fun loadData(): Job {
Expand Down Expand Up @@ -178,7 +179,16 @@ object DataFetcher {

private suspend inline fun <reified T> get(url: String, crossinline block: T.() -> Unit) =
Skytils.IO.launch {
client.get(url).body<T>().apply(block)
runCatching {
client.get(url).body<T>().apply(block)
}.onFailure {
it.printStackTrace()
UChat.chat("""
|$failPrefix §cFailed to fetch data! Some features may not work as expected.
| URL: $url
| §c${it::class.qualifiedName ?: it::class.jvmName}: ${it.message ?: "Unknown"}
""".trimMargin())
}
}

@JvmStatic
Expand Down

0 comments on commit 6e3a2ac

Please sign in to comment.