diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-08-03 13:39:29 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-08-03 13:39:29 +0200 |
commit | 649f3b836518f242fc3aa1b4301d25bfc7d50049 (patch) | |
tree | 168c28c73b748af4158b7846f7ce55e09f2de69a /src | |
parent | d9ed920bd5cf488934a18258c51c2b7501d4c71f (diff) | |
download | skyhanni-649f3b836518f242fc3aa1b4301d25bfc7d50049.tar.gz skyhanni-649f3b836518f242fc3aa1b4301d25bfc7d50049.tar.bz2 skyhanni-649f3b836518f242fc3aa1b4301d25bfc7d50049.zip |
Catching error if a repo file is missing properly
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/repo/RepoUtils.kt | 5 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/test/command/CopyErrorCommand.kt | 6 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoUtils.kt b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoUtils.kt index 9719c70ff..db4735aeb 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoUtils.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.data.repo +import at.hannibal2.skyhanni.test.command.CopyErrorCommand import com.google.gson.Gson import java.io.* import java.nio.charset.StandardCharsets @@ -79,6 +80,10 @@ object RepoUtils { fun <T> getConstant(repo: File, constant: String, gson: Gson, clazz: Class<T>?): T? { if (repo.exists()) { val jsonFile = File(repo, "constants/$constant.json") + if (!jsonFile.isFile) { + CopyErrorCommand.logError(Error("File '$jsonFile' not found!"), "File in repo missing! ($jsonFile). Try §e/shupdaterepo") + return null + } BufferedReader( InputStreamReader( FileInputStream(jsonFile), diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/CopyErrorCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/CopyErrorCommand.kt index 1ae398e4c..69288a896 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/CopyErrorCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/CopyErrorCommand.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.test.command import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.OSUtils +import at.hannibal2.skyhanni.utils.StringUtils.removeColor import com.google.common.cache.CacheBuilder import net.minecraft.client.Minecraft import java.util.* @@ -51,9 +52,10 @@ object CopyErrorCommand { val stackTrace = throwable.getExactStackTrace(false).joinToString("\n").removeSpam() val randomId = UUID.randomUUID().toString() - errorMessages[randomId] = "```\nSkyHanni ${SkyHanniMod.version}: $message\n \n$stackTrace\n```" + val rawMessage = message.removeColor() + errorMessages[randomId] = "```\nSkyHanni ${SkyHanniMod.version}: $rawMessage\n \n$stackTrace\n```" fullErrorMessages[randomId] = - "```\nSkyHanni ${SkyHanniMod.version}: $message\n(full stack trace)\n \n$fullStackTrace\n```" + "```\nSkyHanni ${SkyHanniMod.version}: $rawMessage\n(full stack trace)\n \n$fullStackTrace\n```" LorenzUtils.clickableChat( "§c[SkyHanni ${SkyHanniMod.version}]: $message§c. Click here to copy the error into the clipboard.", |