Hide repeated error messages in logs
This commit is contained in:
@@ -16,7 +16,10 @@ import moe.nea.firmament.Firmament
|
|||||||
* Subscriptions may not necessarily be delivered in the order of registering.
|
* Subscriptions may not necessarily be delivered in the order of registering.
|
||||||
*/
|
*/
|
||||||
open class FirmamentEventBus<T : FirmamentEvent> {
|
open class FirmamentEventBus<T : FirmamentEvent> {
|
||||||
data class Handler<T>(val invocation: (T) -> Unit, val receivesCancelled: Boolean)
|
data class Handler<T>(
|
||||||
|
val invocation: (T) -> Unit, val receivesCancelled: Boolean,
|
||||||
|
var knownErrors: MutableSet<Class<*>> = mutableSetOf(),
|
||||||
|
)
|
||||||
|
|
||||||
private val toHandle: MutableList<Handler<T>> = CopyOnWriteArrayList()
|
private val toHandle: MutableList<Handler<T>> = CopyOnWriteArrayList()
|
||||||
fun subscribe(handle: (T) -> Unit) {
|
fun subscribe(handle: (T) -> Unit) {
|
||||||
@@ -33,7 +36,11 @@ open class FirmamentEventBus<T : FirmamentEvent> {
|
|||||||
try {
|
try {
|
||||||
function.invocation(event)
|
function.invocation(event)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Firmament.logger.error("Caught exception during processing event $event by $function", e)
|
val klass = e.javaClass
|
||||||
|
if (!function.knownErrors.contains(klass) || Firmament.DEBUG) {
|
||||||
|
function.knownErrors.add(klass)
|
||||||
|
Firmament.logger.error("Caught exception during processing event $event by $function", e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ object CustomSkyBlockTextures : FirmamentFeature {
|
|||||||
it.overrideModel = ModelIdentifier("firmskyblock", id.identifier.path, "inventory")
|
it.overrideModel = ModelIdentifier("firmskyblock", id.identifier.path, "inventory")
|
||||||
}
|
}
|
||||||
TickEvent.subscribe {
|
TickEvent.subscribe {
|
||||||
|
throw RuntimeException()
|
||||||
if (TConfig.cacheDuration < 1 || it.tickCount % TConfig.cacheDuration == 0) {
|
if (TConfig.cacheDuration < 1 || it.tickCount % TConfig.cacheDuration == 0) {
|
||||||
CustomItemModelEvent.clearCache()
|
CustomItemModelEvent.clearCache()
|
||||||
skullTextureCache.clear()
|
skullTextureCache.clear()
|
||||||
|
|||||||
Reference in New Issue
Block a user