aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-03-17 11:41:27 +0100
committerGitHub <noreply@github.com>2024-03-17 11:41:27 +0100
commit70d28d6e2ec3fdb9babe632d49c36fad6e7f683c (patch)
tree631500e238aeec2a1ae19913977ec9f4a4379d04 /src/main/java/at/hannibal2
parent6137bea273ef3e8932af218b45fd27c42d355d6e (diff)
downloadskyhanni-70d28d6e2ec3fdb9babe632d49c36fad6e7f683c.tar.gz
skyhanni-70d28d6e2ec3fdb9babe632d49c36fad6e7f683c.tar.bz2
skyhanni-70d28d6e2ec3fdb9babe632d49c36fad6e7f683c.zip
Fix: OpenBrowser Crash (#1195)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt11
2 files changed, 14 insertions, 8 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt b/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt
index 16757d255..e7d0fa3cb 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt
@@ -113,18 +113,17 @@ object ErrorManager {
noStackTrace: Boolean,
vararg extraData: Pair<String, Any?>,
) {
- val error = Error(message, throwable)
- error.printStackTrace()
- Minecraft.getMinecraft().thePlayer ?: return
-
if (!ignoreErrorCache) {
val pair = if (throwable.stackTrace.isNotEmpty()) {
- throwable.stackTrace[0].let { it.fileName!! to it.lineNumber }
+ throwable.stackTrace[0].let { (it.fileName ?: "<unknown>") to it.lineNumber }
} else message to 0
if (cache.contains(pair)) return
cache.add(pair)
}
+ Error(message, throwable).printStackTrace()
+ Minecraft.getMinecraft().thePlayer ?: return
+
val fullStackTrace: String
val stackTrace: String
@@ -175,7 +174,7 @@ object ErrorManager {
private fun Throwable.getCustomStackTrace(
fullStackTrace: Boolean,
- parent: List<String> = emptyList()
+ parent: List<String> = emptyList(),
): List<String> = buildList {
add("Caused by ${this@getCustomStackTrace.javaClass.name}: $message")
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt
index 812bf085f..e209e0ce9 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt
@@ -9,7 +9,9 @@ object OSUtils {
@JvmStatic
fun openBrowser(url: String) {
- if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
+ val desktopSupported = Desktop.isDesktopSupported()
+ val supportedActionBrowse = Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)
+ if (desktopSupported && supportedActionBrowse) {
try {
Desktop.getDesktop().browse(URI(url))
} catch (e: IOException) {
@@ -20,7 +22,12 @@ object OSUtils {
}
} else {
copyToClipboard(url)
- ErrorManager.skyHanniError("Cannot open website, web browser is not supported! Copied url to clipboard.")
+ ErrorManager.logErrorStateWithData(
+ "Cannot open website! Copied url to clipboard instead", "Web browser is not supported",
+ "url" to url,
+ "desktopSupported" to desktopSupported,
+ "supportedActionBrowse" to supportedActionBrowse,
+ )
}
}