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 fd8353fd..fb8c2f1b 100644 --- a/src/main/kotlin/com/beust/kobalt/app/remote/GetDependencyGraphHandler.kt +++ b/src/main/kotlin/com/beust/kobalt/app/remote/GetDependencyGraphHandler.kt @@ -33,8 +33,10 @@ class GetDependencyGraphHandler : WebSocketListener { throw UnsupportedOperationException() } - fun sendWebsocketCommand(endpoint: RemoteEndpoint, commandName: String, payload: T) { - endpoint.sendString(Gson().toJson(WebSocketCommand(commandName, payload = Gson().toJson(payload)))) + fun sendWebsocketCommand(endpoint: RemoteEndpoint, commandName: String, payload: T, + errorMessage: String? = null) { + endpoint.sendString(Gson().toJson(WebSocketCommand(commandName, payload = Gson().toJson(payload), + errorMessage = errorMessage))) } override fun onWebSocketConnect(s: Session) { @@ -74,7 +76,7 @@ class GetDependencyGraphHandler : WebSocketListener { }, useGraph = true) } catch(ex: Throwable) { Exceptions.printStackTrace(ex) - val errorMessage = ex.stackTrace.map { it.toString() }.joinToString("\n

") + val errorMessage = ex.message RemoteDependencyData.GetDependenciesData(errorMessage = errorMessage) } finally { SparkServer.cleanUpCallback() @@ -84,7 +86,8 @@ class GetDependencyGraphHandler : WebSocketListener { RemoteDependencyData.GetDependenciesData( errorMessage = "buildFile wasn't passed in the query parameter") } - sendWebsocketCommand(s.remote, RemoteDependencyData.GetDependenciesData.NAME, result) + sendWebsocketCommand(s.remote, RemoteDependencyData.GetDependenciesData.NAME, result, + errorMessage = result.errorMessage) s.close() } } diff --git a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt index 8c9418f9..5b805676 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt @@ -185,8 +185,10 @@ class KotlinCompiler @Inject constructor( override fun report(severity: CompilerMessageSeverity, message: String, location: CompilerMessageLocation) { if (severity.isError) { - System.err.println(location.dump(message)) - throw KobaltException("Couldn't compile file: $message") + "Couldn't compile file: ${location.dump(message)}".let { fullMessage -> + System.err.println(fullMessage) + throw KobaltException(fullMessage) + } } else if (severity == CompilerMessageSeverity.WARNING && KobaltLogger.LOG_LEVEL >= 2) { warn(location.dump(message)) } else if (severity == CompilerMessageSeverity.INFO && KobaltLogger.LOG_LEVEL >= 2) {