-
-
Notifications
You must be signed in to change notification settings - Fork 307
Backend: Move ErrorManager Consts to Repo #4514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
DavidArthurCole
wants to merge
4
commits into
hannibal002:beta
Choose a base branch
from
DavidArthurCole:backend/strip-stack
base: beta
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
fe77bb8
backend: move constants to repo-load
DavidArthurCole 259c5e9
Merge branch 'beta' into backend/strip-stack
DavidArthurCole 769ce32
Merge branch 'beta' into backend/strip-stack
DavidArthurCole 244c6f8
Merge branch 'hannibal002:beta' into backend/strip-stack
DavidArthurCole File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ErrorManagerJson.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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( | ||
| @Expose val breakAfter: List<String>, | ||
| @Expose val replacements: Map<String, String>, | ||
| @Expose val entireReplacements: Map<String, String>, | ||
| @Expose val ignored: List<String>, | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
@@ -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" | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.", | ||
|
|
@@ -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 | ||
|
|
@@ -289,6 +293,12 @@ object ErrorManager { | |
|
|
||
| @HandleEvent | ||
| fun onRepoReload(event: RepositoryReloadEvent) { | ||
| val repoData = event.getConstant<ErrorManagerJson>("ErrorManager") | ||
| breakAfter = repoData.breakAfter | ||
| replace = repoData.replacements | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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