Skip to content

Commit

Permalink
rx: better error handlin
Browse files Browse the repository at this point in the history
  • Loading branch information
RitikShah committed Feb 26, 2021
1 parent 1a29051 commit 139592e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fabric_version=0.31.0+1.16
loom_version=0.5-SNAPSHOT

# Mod Properties
mod_version = 0.1.1
mod_version = 0.1.2
maven_group = net.rx.modules
archives_base_name = gitmod

Expand Down
11 changes: 10 additions & 1 deletion src/main/kotlin/net/rx/modules/GitConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,16 @@ object GitConfig {


private fun readFromFile(dataFile: File): Config {
return Json.decodeFromString(Config.serializer(), dataFile.readText())
return try {
Json.decodeFromString(Config.serializer(), dataFile.readText())
} catch (e : Throwable) {
println("[GitMod] Invalid JSON. Replacing with default")
config = Config()
fixGitPath()
writeToFile(dataFile, config)

config
}
}

private fun writeToFile(dataFile: File, data: Config) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
"depends": {
"fabricloader": ">=0.8.7",
"fabric": "*",
"fabric-language-kotlin": "*",
"fabric-language-kotlin": ">=1.4.30",
"minecraft": "1.16.x"
},
"requires": {
"fabric-language-kotlin": "*"
"fabric-language-kotlin": ">=1.4.30"
},
"suggests": {
"flamingo": "*"
Expand Down

0 comments on commit 139592e

Please sign in to comment.