Make exceptions anonymous where they're not used

This commit is contained in:
Username404 2021-12-26 22:59:46 +01:00
parent e90c9c1bb0
commit 0e4772873a
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
4 changed files with 5 additions and 5 deletions

View File

@ -121,4 +121,4 @@ val SnowyConfigScreen: Screen = object: Screen(translationComponent) {
)
}
}.build()
} catch (e: ClassNotFoundException) { field }
} catch (_: ClassNotFoundException) { field }

View File

@ -62,7 +62,7 @@ object Configuration {
setReadable(true)
} else try {
result = parseFile(file)
} catch (e: ConfigException) {
} catch (_: ConfigException) {
Snowy.logs.warn("Could not parse the snowy configuration file, the default configuration will be used instead.")
}
}

View File

@ -41,10 +41,10 @@ sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
*Snowy.annotatedButtons.mapNotNull {
try {
it.getConstructor().newInstance()
} catch (e: NoSuchMethodException) {
} catch (_: NoSuchMethodException) {
try {
it.getDeclaredField("INSTANCE").get(null)
} catch (e: NoSuchFieldException) {}
} catch (_: NoSuchFieldException) {}
} as? ButtonImpl
}.plus(Configuration.foundMacros).toTypedArray()
)

View File

@ -22,7 +22,7 @@ object DiscordRPC: ButtonImpl() {
try {
discord_rpc.discordInitialize("839058922102849538", RPCHandlers, true)
Runtime.getRuntime().addShutdownHook(Thread { discord_rpc.discordShutdown() })
} catch (e: UnsatisfiedLinkError) {
} catch (_: UnsatisfiedLinkError) {
Snowy.logs.error("Could not initialize DiscordRPC because the needed libraries are not present on your operating system; the feature will therefore be disabled.")
isDisabled = true
}