diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/aether/ConsoleTransferListener.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/aether/ConsoleTransferListener.kt index 90db0abf..ea6afb53 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/aether/ConsoleTransferListener.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/aether/ConsoleTransferListener.kt @@ -102,7 +102,7 @@ class ConsoleTransferListener @JvmOverloads constructor(out: PrintStream? = null if (event.exception !is MetadataNotFoundException) { if (KobaltLogger.LOG_LEVEL > 2) { - event.exception.printStackTrace(out) + Exceptions.printStackTrace(event.exception) } } } @@ -117,7 +117,7 @@ class ConsoleTransferListener @JvmOverloads constructor(out: PrintStream? = null } override fun transferCorrupted(event: TransferEvent?) { - event!!.exception.printStackTrace(out) + Exceptions.printStackTrace(event!!.exception) } protected fun toKB(bytes: Long): Long { diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/aether/Exceptions.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/aether/Exceptions.kt new file mode 100644 index 00000000..37fcda39 --- /dev/null +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/aether/Exceptions.kt @@ -0,0 +1,14 @@ +package com.beust.kobalt.maven.aether + +object Exceptions { + fun printStackTrace(t: Throwable) { + t.printStackTrace(System.out) + +// println("PRINT STACK TRACE FOR $t") +// t.printStackTrace(System.out) +// println(t.message) +// t.stackTrace.forEach { +// println(" " + it) +// } + } +} diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/aether/ManualRepositorySystemFactory.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/aether/ManualRepositorySystemFactory.kt index fc21c0de..7f019533 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/aether/ManualRepositorySystemFactory.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/aether/ManualRepositorySystemFactory.kt @@ -27,7 +27,7 @@ object ManualRepositorySystemFactory { locator.setErrorHandler(object : DefaultServiceLocator.ErrorHandler() { override fun serviceCreationFailed(type: Class<*>, impl: Class<*>, exception: Throwable) { - exception.printStackTrace() + Exceptions.printStackTrace(exception) } }) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/GithubApi2.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/GithubApi2.kt index 6745e88d..62ee08dd 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/GithubApi2.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/GithubApi2.kt @@ -4,6 +4,7 @@ import com.beust.kobalt.KobaltException import com.beust.kobalt.internal.DocUrl import com.beust.kobalt.internal.KobaltSettings import com.beust.kobalt.maven.Http +import com.beust.kobalt.maven.aether.Exceptions import com.google.gson.Gson import com.google.gson.annotations.SerializedName import com.google.inject.Inject @@ -132,7 +133,7 @@ class GithubApi2 @Inject constructor( } } catch(e: Exception) { kobaltLog(1, "Couldn't retrieve releases from github: " + e.message) - e.printStackTrace() + Exceptions.printStackTrace(e) // val error = parseRetrofitError(e) // val details = if (error.errors != null) { // error.errors[0] diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/KobaltLogger.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/KobaltLogger.kt index 5a439357..3aa80c3e 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/KobaltLogger.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/KobaltLogger.kt @@ -4,6 +4,7 @@ import com.beust.kobalt.Args import com.beust.kobalt.AsciiArt import com.beust.kobalt.KobaltException import com.beust.kobalt.api.Kobalt +import com.beust.kobalt.maven.aether.Exceptions import java.time.LocalDateTime import java.time.format.DateTimeFormatter @@ -81,7 +82,9 @@ class Logger(val dev: Boolean) { println(AsciiArt.errorColor(getPattern("E", shortMessage, longMessage, tag))) if (KobaltLogger.LOG_LEVEL > 1) { - e?.printStackTrace() + val t = e as Throwable + Exceptions.printStackTrace(t) +// e?.printStackTrace() } } @@ -89,7 +92,7 @@ class Logger(val dev: Boolean) { val fullMessage = "***** WARNING " + (e?.message ?: message) println(AsciiArt.Companion.warnColor(getPattern("W", fullMessage, fullMessage, tag))) if (KobaltLogger.LOG_LEVEL > 1) { - e?.printStackTrace() + Exceptions.printStackTrace(e!!) } } diff --git a/src/main/kotlin/com/beust/kobalt/app/remote/GetDependencyGraphHandler.kt b/src/main/kotlin/com/beust/kobalt/app/remote/GetDependencyGraphHandler.kt index 9b066a1e..498baf1d 100644 --- a/src/main/kotlin/com/beust/kobalt/app/remote/GetDependencyGraphHandler.kt +++ b/src/main/kotlin/com/beust/kobalt/app/remote/GetDependencyGraphHandler.kt @@ -5,6 +5,7 @@ import com.beust.kobalt.api.Kobalt import com.beust.kobalt.app.ProjectFinder import com.beust.kobalt.internal.build.BuildFile import com.beust.kobalt.internal.eventbus.ArtifactDownloadedEvent +import com.beust.kobalt.maven.aether.Exceptions import com.google.common.eventbus.EventBus import com.google.common.eventbus.Subscribe import com.google.gson.Gson @@ -28,7 +29,7 @@ class GetDependencyGraphHandler : WebSocketListener { } override fun onWebSocketError(cause: Throwable?) { - cause?.printStackTrace() + Exceptions.printStackTrace(cause) throw UnsupportedOperationException() } @@ -72,7 +73,7 @@ class GetDependencyGraphHandler : WebSocketListener { } }, useGraph = true) } catch(ex: Throwable) { - ex.printStackTrace() + Exceptions.printStackTrace(ex) val errorMessage = ex.stackTrace.map { it.toString() }.joinToString("\n

") DependencyData.GetDependenciesData(errorMessage = errorMessage) } finally { diff --git a/src/main/kotlin/com/beust/kobalt/app/remote/KobaltClient.kt b/src/main/kotlin/com/beust/kobalt/app/remote/KobaltClient.kt index e4788867..dd4720c2 100644 --- a/src/main/kotlin/com/beust/kobalt/app/remote/KobaltClient.kt +++ b/src/main/kotlin/com/beust/kobalt/app/remote/KobaltClient.kt @@ -7,6 +7,7 @@ import com.beust.kobalt.api.Kobalt import com.beust.kobalt.app.MainModule import com.beust.kobalt.homeDir import com.beust.kobalt.internal.KobaltSettings +import com.beust.kobalt.maven.aether.Exceptions import com.beust.kobalt.misc.KFiles import com.beust.kobalt.misc.kobaltLog import com.beust.kobalt.misc.warn @@ -71,7 +72,7 @@ class KobaltWebSocketClient : Runnable { } override fun onFailure(ex: IOException, response: Response?) { - ex.printStackTrace() + Exceptions.printStackTrace(ex) error("WebSocket failure: ${ex.message} response: $response") } diff --git a/src/main/kotlin/com/beust/kobalt/app/remote/KobaltServer.kt b/src/main/kotlin/com/beust/kobalt/app/remote/KobaltServer.kt index 4fe9b023..b61c809f 100644 --- a/src/main/kotlin/com/beust/kobalt/app/remote/KobaltServer.kt +++ b/src/main/kotlin/com/beust/kobalt/app/remote/KobaltServer.kt @@ -3,6 +3,7 @@ package com.beust.kobalt.app.remote import com.beust.kobalt.api.Project import com.beust.kobalt.homeDir import com.beust.kobalt.internal.PluginInfo +import com.beust.kobalt.maven.aether.Exceptions import com.beust.kobalt.misc.KFiles import com.beust.kobalt.misc.kobaltLog import com.google.inject.Inject @@ -56,7 +57,7 @@ class KobaltServer @Inject constructor(@Assisted val force: Boolean, @Assisted @ // WasabiServer(initCallback, cleanUpCallback).run(port) } } catch(ex: Exception) { - ex.printStackTrace() + Exceptions.printStackTrace(ex) } finally { // deleteServerFile() } diff --git a/src/main/kotlin/com/beust/kobalt/app/remote/SparkServer.kt b/src/main/kotlin/com/beust/kobalt/app/remote/SparkServer.kt index 435e2ef7..dccea702 100644 --- a/src/main/kotlin/com/beust/kobalt/app/remote/SparkServer.kt +++ b/src/main/kotlin/com/beust/kobalt/app/remote/SparkServer.kt @@ -9,6 +9,7 @@ import com.beust.kobalt.app.Templates import com.beust.kobalt.internal.PluginInfo import com.beust.kobalt.internal.build.BuildFile import com.beust.kobalt.internal.eventbus.ArtifactDownloadedEvent +import com.beust.kobalt.maven.aether.Exceptions import com.google.common.collect.ListMultimap import com.google.common.eventbus.EventBus import com.google.common.eventbus.Subscribe @@ -110,7 +111,7 @@ class GetDependenciesHandler : WebSocketListener { } override fun onWebSocketError(cause: Throwable?) { - cause?.printStackTrace() + Exceptions.printStackTrace(cause) throw UnsupportedOperationException() }