Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package at.hannibal2.skyhanni.data.jsonobjects.repo

import com.google.gson.annotations.Expose

data class ErrorManagerJson(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please do not use camel case names in the json. e.g. in the json, use break_after, then use @SerializedName to map this to the kotlin variable breakAfter

@Expose val breakAfter: List<String>,
@Expose val replacements: Map<String, String>,
@Expose val entireReplacements: Map<String, String>,
@Expose val ignored: List<String>,
)
36 changes: 23 additions & 13 deletions src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.config.commands.CommandCategory
import at.hannibal2.skyhanni.config.commands.CommandRegistrationEvent
import at.hannibal2.skyhanni.data.jsonobjects.repo.ChangedChatErrorsJson
import at.hannibal2.skyhanni.data.jsonobjects.repo.ErrorManagerJson
import at.hannibal2.skyhanni.data.jsonobjects.repo.RepoErrorData
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
Expand Down Expand Up @@ -35,36 +36,32 @@ fun requireDevEnv(value: Boolean, lazyMessage: (() -> Any)?) {
@SkyHanniModule
object ErrorManager {

// random id -> error message
private val errorMessages = mutableMapOf<String, String>()
private val fullErrorMessages = mutableMapOf<String, String>()
private val cache = TimeLimitedSet<CachedError>(10.minutes)
private var repoErrors: List<RepoErrorData> = emptyList()

private val breakAfter = listOf(
// These are left as mutable properties so that they can be updated by the repo
// however we still want to leave some defaults in here in case a repo reload fails
// and tries to call ErrorManager methods.
// <editor-fold defaultstate="collapsed" desc="Error Manager Data (semi-REPO controlled)">
private var breakAfter: List<String> = listOf(
"at at.hannibal2.skyhanni.config.commands.Commands\$createCommand",
"at net.minecraftforge.fml.common.eventhandler.EventBus.post",
"at at.hannibal2.skyhanni.mixins.hooks.NetHandlerPlayClientHookKt.onSendPacket",
"at net.minecraft.client.main.Main.main",
"at.hannibal2.skyhanni.api.event.EventListeners.createZeroParameterConsumer",
"at.hannibal2.skyhanni.api.event.EventListeners.createSingleParameterConsumer",
"at.hannibal2.skyhanni.api.event.SkyHanniEvent.post"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add the trailing comma

)

private val replace = mapOf(
private var replace: Map<String, String> = mapOf(
"at.hannibal2.skyhanni." to "SH.",
"io.moulberry.notenoughupdates." to "NEU.",
"net.minecraft." to "MC.",
"net.minecraftforge.fml." to "FML.",
"knot//" to "",
"java.base/" to "",
)

private val replaceEntirely = mapOf(
private var replaceEntirely: Map<String, String> = mapOf(
"at.hannibal2.skyhanni.api.event.EventListeners.createZeroParameterConsumer" to "<Skyhanni event post>",
"at.hannibal2.skyhanni.api.event.EventListeners.createSingleParameterConsumer" to "<Skyhanni event post>",
)

private val ignored = listOf(
private var ignored: List<String> = listOf(
"at java.lang.Thread.run",
"at java.util.concurrent.",
"at java.lang.reflect.",
Expand All @@ -85,6 +82,13 @@ object ErrorManager {
"at at.hannibal2.skyhanni.api.event.EventHandler.post",
"at net.minecraft.launchwrapper.",
)
// </editor-fold>

// random id -> error message
private val errorMessages = mutableMapOf<String, String>()
private val fullErrorMessages = mutableMapOf<String, String>()
private val cache = TimeLimitedSet<CachedError>(10.minutes)
private var repoErrors: List<RepoErrorData> = emptyList()

// this hides the whole stack trace of one error of the list of all errors in the error message
// where the error class name is the key and the first line contains one of the entries in the list of values
Expand Down Expand Up @@ -289,6 +293,12 @@ object ErrorManager {

@HandleEvent
fun onRepoReload(event: RepositoryReloadEvent) {
val repoData = event.getConstant<ErrorManagerJson>("ErrorManager")
breakAfter = repoData.breakAfter
replace = repoData.replacements
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use consistent variable names, for replace vs replacements and replace entirely vs entire replacements

replaceEntirely = repoData.entireReplacements
ignored = repoData.ignored

val data = event.getConstant<ChangedChatErrorsJson>("ChangedChatErrors")
val version = SkyHanniMod.modVersion

Expand Down
Loading