mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Send the correct error message to the WebSocket.
This commit is contained in:
parent
263e755094
commit
fc5d9bb2b1
2 changed files with 11 additions and 6 deletions
|
@ -33,8 +33,10 @@ class GetDependencyGraphHandler : WebSocketListener {
|
|||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
fun <T> sendWebsocketCommand(endpoint: RemoteEndpoint, commandName: String, payload: T) {
|
||||
endpoint.sendString(Gson().toJson(WebSocketCommand(commandName, payload = Gson().toJson(payload))))
|
||||
fun <T> 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<p>")
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue