mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-27 00:38:11 -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()
|
throw UnsupportedOperationException()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T> sendWebsocketCommand(endpoint: RemoteEndpoint, commandName: String, payload: T) {
|
fun <T> sendWebsocketCommand(endpoint: RemoteEndpoint, commandName: String, payload: T,
|
||||||
endpoint.sendString(Gson().toJson(WebSocketCommand(commandName, payload = Gson().toJson(payload))))
|
errorMessage: String? = null) {
|
||||||
|
endpoint.sendString(Gson().toJson(WebSocketCommand(commandName, payload = Gson().toJson(payload),
|
||||||
|
errorMessage = errorMessage)))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onWebSocketConnect(s: Session) {
|
override fun onWebSocketConnect(s: Session) {
|
||||||
|
@ -74,7 +76,7 @@ class GetDependencyGraphHandler : WebSocketListener {
|
||||||
}, useGraph = true)
|
}, useGraph = true)
|
||||||
} catch(ex: Throwable) {
|
} catch(ex: Throwable) {
|
||||||
Exceptions.printStackTrace(ex)
|
Exceptions.printStackTrace(ex)
|
||||||
val errorMessage = ex.stackTrace.map { it.toString() }.joinToString("\n<p>")
|
val errorMessage = ex.message
|
||||||
RemoteDependencyData.GetDependenciesData(errorMessage = errorMessage)
|
RemoteDependencyData.GetDependenciesData(errorMessage = errorMessage)
|
||||||
} finally {
|
} finally {
|
||||||
SparkServer.cleanUpCallback()
|
SparkServer.cleanUpCallback()
|
||||||
|
@ -84,7 +86,8 @@ class GetDependencyGraphHandler : WebSocketListener {
|
||||||
RemoteDependencyData.GetDependenciesData(
|
RemoteDependencyData.GetDependenciesData(
|
||||||
errorMessage = "buildFile wasn't passed in the query parameter")
|
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()
|
s.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,8 +185,10 @@ class KotlinCompiler @Inject constructor(
|
||||||
override fun report(severity: CompilerMessageSeverity,
|
override fun report(severity: CompilerMessageSeverity,
|
||||||
message: String, location: CompilerMessageLocation) {
|
message: String, location: CompilerMessageLocation) {
|
||||||
if (severity.isError) {
|
if (severity.isError) {
|
||||||
System.err.println(location.dump(message))
|
"Couldn't compile file: ${location.dump(message)}".let { fullMessage ->
|
||||||
throw KobaltException("Couldn't compile file: $message")
|
System.err.println(fullMessage)
|
||||||
|
throw KobaltException(fullMessage)
|
||||||
|
}
|
||||||
} else if (severity == CompilerMessageSeverity.WARNING && KobaltLogger.LOG_LEVEL >= 2) {
|
} else if (severity == CompilerMessageSeverity.WARNING && KobaltLogger.LOG_LEVEL >= 2) {
|
||||||
warn(location.dump(message))
|
warn(location.dump(message))
|
||||||
} else if (severity == CompilerMessageSeverity.INFO && KobaltLogger.LOG_LEVEL >= 2) {
|
} else if (severity == CompilerMessageSeverity.INFO && KobaltLogger.LOG_LEVEL >= 2) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue