aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
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,
+ )
}
}