mirror of https://github.com/sbt/sbt.git
Extract jsonRpcRespondErrorImpl
This commit is contained in:
parent
268b5111ab
commit
d3ef452a5f
|
|
@ -10,6 +10,7 @@ package internal
|
||||||
package server
|
package server
|
||||||
|
|
||||||
import sjsonnew.JsonFormat
|
import sjsonnew.JsonFormat
|
||||||
|
import sjsonnew.shaded.scalajson.ast.unsafe.JValue
|
||||||
import sjsonnew.support.scalajson.unsafe.Converter
|
import sjsonnew.support.scalajson.unsafe.Converter
|
||||||
import sbt.protocol.Serialization
|
import sbt.protocol.Serialization
|
||||||
import sbt.protocol.{ SettingQuery => Q }
|
import sbt.protocol.{ SettingQuery => Q }
|
||||||
|
|
@ -143,16 +144,8 @@ private[sbt] trait LanguageServerProtocol extends CommandChannel { self =>
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Respond back to Language Server's client. */
|
/** Respond back to Language Server's client. */
|
||||||
private[sbt] def jsonRpcRespondError(
|
private[sbt] def jsonRpcRespondError(execId: Option[String], code: Long, message: String): Unit =
|
||||||
execId: Option[String],
|
jsonRpcRespondErrorImpl(execId, code, message, None)
|
||||||
code: Long,
|
|
||||||
message: String,
|
|
||||||
): Unit = {
|
|
||||||
val e = JsonRpcResponseError(code, message, None)
|
|
||||||
val m = JsonRpcResponseMessage("2.0", execId, None, Option(e))
|
|
||||||
val bytes = Serialization.serializeResponseMessage(m)
|
|
||||||
publishBytes(bytes)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Respond back to Language Server's client. */
|
/** Respond back to Language Server's client. */
|
||||||
private[sbt] def jsonRpcRespondError[A: JsonFormat](
|
private[sbt] def jsonRpcRespondError[A: JsonFormat](
|
||||||
|
|
@ -160,8 +153,16 @@ private[sbt] trait LanguageServerProtocol extends CommandChannel { self =>
|
||||||
code: Long,
|
code: Long,
|
||||||
message: String,
|
message: String,
|
||||||
data: A,
|
data: A,
|
||||||
|
): Unit =
|
||||||
|
jsonRpcRespondErrorImpl(execId, code, message, Option(Converter.toJson[A](data).get))
|
||||||
|
|
||||||
|
private[this] def jsonRpcRespondErrorImpl(
|
||||||
|
execId: Option[String],
|
||||||
|
code: Long,
|
||||||
|
message: String,
|
||||||
|
data: Option[JValue],
|
||||||
): Unit = {
|
): Unit = {
|
||||||
val e = JsonRpcResponseError(code, message, Option(Converter.toJson[A](data).get))
|
val e = JsonRpcResponseError(code, message, data)
|
||||||
val m = JsonRpcResponseMessage("2.0", execId, None, Option(e))
|
val m = JsonRpcResponseMessage("2.0", execId, None, Option(e))
|
||||||
val bytes = Serialization.serializeResponseMessage(m)
|
val bytes = Serialization.serializeResponseMessage(m)
|
||||||
publishBytes(bytes)
|
publishBytes(bytes)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue