mirror of
https://github.com/enso-org/enso.git
synced 2024-08-16 16:30:33 +03:00
Fix Error Payload Serialization (#3315)
This commit is contained in:
parent
d3cc2c1025
commit
d3846578cc
@ -4824,7 +4824,7 @@ Signals that the requested file read was out of bounds for the file's size.
|
||||
"error" : {
|
||||
"code" : 1009
|
||||
"message" : "Read is out of bounds for the file"
|
||||
"data" : {
|
||||
"payload" : {
|
||||
"fileLength" : 0
|
||||
}
|
||||
}
|
||||
@ -4927,7 +4927,7 @@ cannot be evaluated. The error contains an optional `data` field of type
|
||||
"error" : {
|
||||
"code" : 2007,
|
||||
"message" : "Evaluation of the visualisation expression failed [i is not defined]"
|
||||
"data" : {
|
||||
"payload" : {
|
||||
"kind" : "Error",
|
||||
"message" : "i is not defined",
|
||||
"path" : null,
|
||||
|
@ -934,7 +934,7 @@ version that is required to complete the related action.
|
||||
"error" : {
|
||||
"code" : 4022,
|
||||
"message" : "Project manager 1.2.3 is required to install the requested engine. Please upgrade.",
|
||||
"data": {
|
||||
"payload": {
|
||||
"minimumRequiredVersion": "1.2.3"
|
||||
}
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ class VisualisationOperationsTest extends BaseServerTest {
|
||||
"error" : {
|
||||
"code" : 2007,
|
||||
"message" : $errorMessage,
|
||||
"data": {
|
||||
"payload": {
|
||||
"kind" : "Error",
|
||||
"message" : $expressionFailureMessage,
|
||||
"path" : null,
|
||||
|
@ -31,7 +31,7 @@ object JsonProtocol {
|
||||
case class ResponseError(id: Option[Id], error: ErrorData) extends JsonMessage
|
||||
|
||||
/** The error response details. */
|
||||
case class ErrorData(code: Int, message: String, data: Option[Json])
|
||||
case class ErrorData(code: Int, message: String, payload: Option[Json])
|
||||
|
||||
object Constants {
|
||||
val jsonrpc: String = "jsonrpc"
|
||||
@ -44,7 +44,7 @@ object JsonProtocol {
|
||||
val error: String = "error"
|
||||
val code: String = "code"
|
||||
val message: String = "message"
|
||||
val data: String = "data"
|
||||
val payload: String = "payload"
|
||||
}
|
||||
|
||||
implicit val notificationEncoder: Encoder[Notification] =
|
||||
@ -84,9 +84,9 @@ object JsonProtocol {
|
||||
Constants.code -> errorData.code.asJson,
|
||||
Constants.message -> errorData.message.asJson
|
||||
)
|
||||
val result = errorData.data match {
|
||||
val result = errorData.payload match {
|
||||
case Some(additionalPayload) =>
|
||||
base.+:(Constants.data -> additionalPayload)
|
||||
base.+:(Constants.payload -> additionalPayload)
|
||||
case None =>
|
||||
base
|
||||
}
|
||||
|
@ -142,7 +142,11 @@ class MessageHandler(val protocol: Protocol, val controller: ActorRef)
|
||||
.resolveError(bareError.code)
|
||||
.getOrElse(
|
||||
Errors
|
||||
.UnknownError(bareError.code, bareError.message, bareError.data)
|
||||
.UnknownError(
|
||||
bareError.code,
|
||||
bareError.message,
|
||||
bareError.payload
|
||||
)
|
||||
)
|
||||
controller ! ResponseError(mayId, error)
|
||||
mayId.foreach(id =>
|
||||
@ -154,7 +158,7 @@ class MessageHandler(val protocol: Protocol, val controller: ActorRef)
|
||||
|
||||
private def makeError(id: Option[Id], error: Error): String = {
|
||||
val bareError =
|
||||
JsonProtocol.ErrorData(error.code, error.message, data = error.payload)
|
||||
JsonProtocol.ErrorData(error.code, error.message, error.payload)
|
||||
val bareErrorResponse = JsonProtocol.ResponseError(id, bareError)
|
||||
JsonProtocol.encode(bareErrorResponse)
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ class ProjectCreateDefaultToLatestSpec
|
||||
"error": {
|
||||
"code": 4022,
|
||||
"message": $message,
|
||||
"data" : {
|
||||
"payload" : {
|
||||
"minimumRequiredVersion" : "9999.0.0"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user