rad
04/06/2025, 11:41 AMCoroutineContext
with two exception handlers: one that is mine, and one from a different library (inlined hidden impl) which I'm trying to both remove to add a new one. Currently doing this:
override val coroutineContext: CoroutineContext get() = syncContext
.minusKey(CoroutineExceptionHandler)
.minusKey(CoroutineExceptionHandler)
.plus(GameInstanceExceptionHandler(this))
But I'm still getting the one hidden exception handler in the context. Here's what happens when I print it:
[com.github.shynixn.mccoroutine.bukkit.impl.CoroutineSessionImpl$special$$inlined$CoroutineExceptionHandler$1@5e90d7d5, net.radsteve.axi.game.instance.GameInstanceExceptionHandler@47f46d1f, net.radsteve.axi.event.CurrentlyCalledEvent@332cca3, kotlinx.coroutines.UndispatchedMarker@b19f379, UndispatchedCoroutine{Active}@2d6e9d46, MinecraftCoroutineDispatcher@6a486f9c]
How can I remove this first exception handler in here?rad
04/06/2025, 11:47 AMrad
04/06/2025, 1:17 PMoverride val coroutineContext: CoroutineContext by lazy {
syncContext.fold(GameInstanceExceptionHandler(this) as CoroutineContext) { acc, elem ->
if (elem.key == CoroutineExceptionHandler) {
acc
} else {
acc + elem
}
}
}
This works, but I'm calling withContext
with this context on an existing coroutine context with another context element I don't want. Is there any way to prevent it from merging?rad
04/06/2025, 1:28 PM