Skip to content

Commit

Permalink
Fix/electron launch error not logged (#895)
Browse files Browse the repository at this point in the history
* Log "Browser::openInBrowser" errors

The error was never written to the log file.
It was only visible in the console

* Remove "printStackTrace" usage with logs
  • Loading branch information
schroda authored Mar 10, 2024
1 parent b95a8d4 commit 33cbfa9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ fun applicationSetup() {
}
} catch (e: Throwable) {
// cover both java.lang.Exception and java.lang.Error
e.printStackTrace()
logger.error(e) { "Failed to create/remove SystemTray due to" }
}
}, ignoreInitialValue = false)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ package suwayomi.tachidesk.server.util
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

import dorkbox.desktop.Desktop
import mu.KotlinLogging
import suwayomi.tachidesk.server.serverConfig

object Browser {
private val logger = KotlinLogging.logger { }
private val electronInstances = mutableListOf<Any>()

private fun getAppBaseUrl(): String {
Expand All @@ -28,14 +30,14 @@ object Browser {
electronInstances.add(ProcessBuilder(electronPath, appBaseUrl).start())
} catch (e: Throwable) {
// cover both java.lang.Exception and java.lang.Error
e.printStackTrace()
logger.error(e) { "openInBrowser: failed to launch electron due to" }
}
} else {
try {
Desktop.browseURL(appBaseUrl)
} catch (e: Throwable) {
// cover both java.lang.Exception and java.lang.Error
e.printStackTrace()
logger.error(e) { "openInBrowser: failed to launch browser due to" }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ package suwayomi.tachidesk.server.util
import dorkbox.systemTray.MenuItem
import dorkbox.systemTray.SystemTray
import dorkbox.util.CacheUtil
import mu.KotlinLogging
import suwayomi.tachidesk.server.ServerConfig
import suwayomi.tachidesk.server.generated.BuildConfig
import suwayomi.tachidesk.server.serverConfig
import suwayomi.tachidesk.server.util.Browser.openInBrowser
import suwayomi.tachidesk.server.util.ExitCode.Success

object SystemTray {
private val logger = KotlinLogging.logger { }
private var instance: SystemTray? = null

fun create() {
Expand Down Expand Up @@ -60,7 +62,7 @@ object SystemTray {

systemTray
} catch (e: Exception) {
e.printStackTrace()
logger.error(e) { "create: failed to create SystemTray due to" }
null
}
}
Expand Down

0 comments on commit 33cbfa9

Please sign in to comment.