diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 51ff52a529d..aa1e16efb21 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -10,8 +10,8 @@ /lib/scala/flexer @iamrecursion @kustosz /lib/scala/graph @iamrecursion @kustosz /lib/scala/interpreter-dsl @iamrecursion @kustosz -/lib/scala/json-rpc-server @lolczak @4e6 @iamrecursion -/lib/scala/json-rpc-server-test @lolczak @4e6 @iamrecursion +/lib/scala/json-rpc-server @lolczak @4e6 @iamrecursion @kustosz +/lib/scala/json-rpc-server-test @lolczak @4e6 @iamrecursion @kustosz /lib/scala/logger @kustosz @iamrecursion /lib/scala/parser-service @kustosz @iamrecursion /lib/scala/pkg @iamrecursion @kustosz diff --git a/docs/language-server/protocol-common.md b/docs/language-server/protocol-common.md index 88b783bcfdc..ac581c67474 100644 --- a/docs/language-server/protocol-common.md +++ b/docs/language-server/protocol-common.md @@ -28,6 +28,7 @@ transport formats, please look [here](./protocol-architecture.md). - [`InvalidParams`](#invalidparams) - [`ServiceError`](#serviceerror) - [`NotImplementedError`](#notimplementederror) + - [`RequestTimeoutError`](#requesttimeouterror) @@ -197,3 +198,14 @@ implemented yet. "message" : "The requested method is not implemented" } ``` + +### `RequestTimeoutError` + +Signals that request exceeded the waiting time. + +```typescript +"error" : { + "code" : 11, + "message" : "Request timeout" +} +``` diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/capability/AcquireCapabilityHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/capability/AcquireCapabilityHandler.scala index 507451ae7f1..a9b692d6bea 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/capability/AcquireCapabilityHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/capability/AcquireCapabilityHandler.scala @@ -1,7 +1,6 @@ package org.enso.languageserver.requesthandler.capability import akka.actor.{Actor, ActorLogging, ActorRef, Cancellable, Props} -import org.enso.jsonrpc.Errors.ServiceError import org.enso.jsonrpc._ import org.enso.languageserver.capability.CapabilityApi.AcquireCapability import org.enso.languageserver.capability.CapabilityProtocol @@ -54,7 +53,7 @@ class AcquireCapabilityHandler( ): Receive = { case RequestTimeout => log.error(s"Acquiring capability for ${session.clientId} timed out") - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.RequestTimeout) context.stop(self) case CapabilityAcquired => @@ -63,7 +62,7 @@ class AcquireCapabilityHandler( context.stop(self) case CapabilityAcquisitionBadRequest => - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.ServiceError) cancellable.cancel() context.stop(self) diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/capability/ReleaseCapabilityHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/capability/ReleaseCapabilityHandler.scala index 3f372b0a9d8..3958c40dde3 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/capability/ReleaseCapabilityHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/capability/ReleaseCapabilityHandler.scala @@ -1,7 +1,6 @@ package org.enso.languageserver.requesthandler.capability import akka.actor.{Actor, ActorLogging, ActorRef, Cancellable, Props} -import org.enso.jsonrpc.Errors.ServiceError import org.enso.jsonrpc._ import org.enso.languageserver.capability.CapabilityApi.{ CapabilityNotAcquired, @@ -52,7 +51,7 @@ class ReleaseCapabilityHandler( ): Receive = { case RequestTimeout => log.error(s"Releasing capability for ${session.clientId} timed out") - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.RequestTimeout) context.stop(self) case CapabilityReleased => @@ -61,7 +60,7 @@ class ReleaseCapabilityHandler( context.stop(self) case CapabilityReleaseBadRequest => - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.ServiceError) cancellable.cancel() context.stop(self) diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/executioncontext/CreateHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/executioncontext/CreateHandler.scala index 60892a760a8..ff64e99563f 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/executioncontext/CreateHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/executioncontext/CreateHandler.scala @@ -1,7 +1,6 @@ package org.enso.languageserver.requesthandler.executioncontext import akka.actor.{Actor, ActorLogging, ActorRef, Cancellable, Props} -import org.enso.jsonrpc.Errors.ServiceError import org.enso.jsonrpc._ import org.enso.languageserver.data.{ CanModify, @@ -53,7 +52,7 @@ class CreateHandler( ): Receive = { case RequestTimeout => log.error(s"Request $id timed out") - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.RequestTimeout) context.stop(self) case CreateContextResponse(contextId) => diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/executioncontext/DestroyHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/executioncontext/DestroyHandler.scala index a7b6315b375..194125a08d8 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/executioncontext/DestroyHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/executioncontext/DestroyHandler.scala @@ -1,7 +1,6 @@ package org.enso.languageserver.requesthandler.executioncontext import akka.actor.{Actor, ActorLogging, ActorRef, Cancellable, Props} -import org.enso.jsonrpc.Errors.ServiceError import org.enso.jsonrpc._ import org.enso.languageserver.requesthandler.RequestTimeout import org.enso.languageserver.runtime.ExecutionApi._ @@ -52,7 +51,7 @@ class DestroyHandler( ): Receive = { case RequestTimeout => log.error(s"Request $id timed out") - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.RequestTimeout) context.stop(self) case DestroyContextResponse(_) => diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/executioncontext/PopHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/executioncontext/PopHandler.scala index 1c8889a4c9c..b372c2099d9 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/executioncontext/PopHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/executioncontext/PopHandler.scala @@ -1,7 +1,6 @@ package org.enso.languageserver.requesthandler.executioncontext import akka.actor.{Actor, ActorLogging, ActorRef, Cancellable, Props} -import org.enso.jsonrpc.Errors.ServiceError import org.enso.jsonrpc._ import org.enso.languageserver.requesthandler.RequestTimeout import org.enso.languageserver.runtime.ExecutionApi._ @@ -48,7 +47,7 @@ class PopHandler( ): Receive = { case RequestTimeout => log.error(s"Request $id timed out") - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.RequestTimeout) context.stop(self) case PopContextResponse(_) => diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/executioncontext/PushHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/executioncontext/PushHandler.scala index 26034678565..411cd0e57d2 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/executioncontext/PushHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/executioncontext/PushHandler.scala @@ -1,7 +1,6 @@ package org.enso.languageserver.requesthandler.executioncontext import akka.actor.{Actor, ActorLogging, ActorRef, Cancellable, Props} -import org.enso.jsonrpc.Errors.ServiceError import org.enso.jsonrpc._ import org.enso.languageserver.requesthandler.RequestTimeout import org.enso.languageserver.runtime.ExecutionApi._ @@ -56,7 +55,7 @@ class PushHandler( ): Receive = { case RequestTimeout => log.error(s"Request $id timed out") - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.RequestTimeout) context.stop(self) case PushContextResponse(_) => diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/executioncontext/RecomputeHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/executioncontext/RecomputeHandler.scala index c26e74abeb3..51b09ed3802 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/executioncontext/RecomputeHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/executioncontext/RecomputeHandler.scala @@ -1,7 +1,6 @@ package org.enso.languageserver.requesthandler.executioncontext import akka.actor.{Actor, ActorLogging, ActorRef, Cancellable, Props} -import org.enso.jsonrpc.Errors.ServiceError import org.enso.jsonrpc._ import org.enso.languageserver.requesthandler.RequestTimeout import org.enso.languageserver.runtime.ExecutionApi._ @@ -56,7 +55,7 @@ class RecomputeHandler( ): Receive = { case RequestTimeout => log.error(s"Request $id timed out") - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.RequestTimeout) context.stop(self) case RecomputeContextResponse(_) => diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/CopyFileHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/CopyFileHandler.scala index b0411126237..e9dad274b42 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/CopyFileHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/CopyFileHandler.scala @@ -1,7 +1,6 @@ package org.enso.languageserver.requesthandler.file import akka.actor._ -import org.enso.jsonrpc.Errors.ServiceError import org.enso.jsonrpc._ import org.enso.languageserver.filemanager.{ FileManagerProtocol, @@ -37,13 +36,13 @@ class CopyFileHandler(requestTimeout: FiniteDuration, fileManager: ActorRef) ): Receive = { case Status.Failure(ex) => log.error(s"Failure during $CopyFile operation:", ex) - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.ServiceError) cancellable.cancel() context.stop(self) case RequestTimeout => log.error(s"Request $id timed out") - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.RequestTimeout) context.stop(self) case FileManagerProtocol.CopyFileResult(Left(failure)) => diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/CreateFileHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/CreateFileHandler.scala index 107521604a0..fdd62e16d58 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/CreateFileHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/CreateFileHandler.scala @@ -1,7 +1,6 @@ package org.enso.languageserver.requesthandler.file import akka.actor._ -import org.enso.jsonrpc.Errors.ServiceError import org.enso.jsonrpc._ import org.enso.languageserver.filemanager.{ FileManagerProtocol, @@ -37,13 +36,13 @@ class CreateFileHandler(requestTimeout: FiniteDuration, fileManager: ActorRef) ): Receive = { case Status.Failure(ex) => log.error(s"Failure during $CreateFile operation:", ex) - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.ServiceError) cancellable.cancel() context.stop(self) case RequestTimeout => log.error(s"Request $id timed out") - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.RequestTimeout) context.stop(self) case FileManagerProtocol.CreateFileResult(Left(failure)) => diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/DeleteFileHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/DeleteFileHandler.scala index 5ac0b48474e..e6497dcce8a 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/DeleteFileHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/DeleteFileHandler.scala @@ -1,7 +1,6 @@ package org.enso.languageserver.requesthandler.file import akka.actor._ -import org.enso.jsonrpc.Errors.ServiceError import org.enso.jsonrpc._ import org.enso.languageserver.filemanager.{ FileDeletedEvent, @@ -40,13 +39,13 @@ class DeleteFileHandler(requestTimeout: FiniteDuration, fileManager: ActorRef) ): Receive = { case Status.Failure(ex) => log.error(s"Failure during $DeleteFile operation:", ex) - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.ServiceError) cancellable.cancel() context.stop(self) case RequestTimeout => log.error(s"Request $id timed out") - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.RequestTimeout) context.stop(self) case FileManagerProtocol.DeleteFileResult(Left(failure)) => diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/ExistsFileHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/ExistsFileHandler.scala index a6e18c982a4..1059f4249e3 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/ExistsFileHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/ExistsFileHandler.scala @@ -1,7 +1,6 @@ package org.enso.languageserver.requesthandler.file import akka.actor._ -import org.enso.jsonrpc.Errors.ServiceError import org.enso.jsonrpc._ import org.enso.languageserver.filemanager.{ FileManagerProtocol, @@ -37,13 +36,13 @@ class ExistsFileHandler(requestTimeout: FiniteDuration, fileManager: ActorRef) ): Receive = { case Status.Failure(ex) => log.error(s"Failure during $ExistsFile operation:", ex) - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.ServiceError) cancellable.cancel() context.stop(self) case RequestTimeout => log.error(s"Request $id timed out") - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.RequestTimeout) context.stop(self) case FileManagerProtocol.ExistsFileResult(Left(failure)) => diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/InfoFileHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/InfoFileHandler.scala index 7cb16adc33b..29c5ccd2fb5 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/InfoFileHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/InfoFileHandler.scala @@ -1,7 +1,6 @@ package org.enso.languageserver.requesthandler.file import akka.actor._ -import org.enso.jsonrpc.Errors.ServiceError import org.enso.jsonrpc._ import org.enso.languageserver.filemanager.{ FileManagerProtocol, @@ -42,13 +41,13 @@ class InfoFileHandler(requestTimeout: FiniteDuration, fileManager: ActorRef) ): Receive = { case Status.Failure(ex) => log.error(s"Failure during $InfoFile operation:", ex) - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.ServiceError) cancellable.cancel() context.stop(self) case RequestTimeout => log.error(s"Request $id timed out") - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.RequestTimeout) context.stop(self) case FileManagerProtocol.InfoFileResult(Left(failure)) => @@ -68,9 +67,9 @@ class InfoFileHandler(requestTimeout: FiniteDuration, fileManager: ActorRef) object InfoFileHandler { - /** Creates a configuration object used to create a [[InfoFileHandler]] + /** Creates a configuration object used to create a [[InfoFileHandler]]. * - * @param requestTimeout a request timeout + * @param timeout a request timeout * @param fileManager a file system manager actor */ def props(timeout: FiniteDuration, fileManager: ActorRef): Props = diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/ListFileHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/ListFileHandler.scala index 4d21523cc0f..5a80539276f 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/ListFileHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/ListFileHandler.scala @@ -1,7 +1,6 @@ package org.enso.languageserver.requesthandler.file import akka.actor._ -import org.enso.jsonrpc.Errors.ServiceError import org.enso.jsonrpc._ import org.enso.languageserver.filemanager.{ FileManagerProtocol, @@ -37,13 +36,13 @@ class ListFileHandler(requestTimeout: FiniteDuration, fileManager: ActorRef) ): Receive = { case Status.Failure(ex) => log.error(s"Failure during $ListFile operation:", ex) - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.ServiceError) cancellable.cancel() context.stop(self) case RequestTimeout => log.error(s"Request $id timed out") - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.RequestTimeout) context.stop(self) case FileManagerProtocol.ListFileResult(Left(failure)) => diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/MoveFileHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/MoveFileHandler.scala index bf670cee606..045053bf92d 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/MoveFileHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/MoveFileHandler.scala @@ -1,7 +1,6 @@ package org.enso.languageserver.requesthandler.file import akka.actor._ -import org.enso.jsonrpc.Errors.ServiceError import org.enso.jsonrpc._ import org.enso.languageserver.filemanager.{ FileManagerProtocol, @@ -37,13 +36,13 @@ class MoveFileHandler(requestTimeout: FiniteDuration, fileManager: ActorRef) ): Receive = { case Status.Failure(ex) => log.error(s"Failure during $MoveFile operation:", ex) - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.ServiceError) cancellable.cancel() context.stop(self) case RequestTimeout => log.error(s"Request $id timed out") - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.RequestTimeout) context.stop(self) case FileManagerProtocol.MoveFileResult(Left(failure)) => diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/ReadTextualFileHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/ReadTextualFileHandler.scala index 427b6c3723c..c95c14c9018 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/ReadTextualFileHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/ReadTextualFileHandler.scala @@ -1,7 +1,6 @@ package org.enso.languageserver.requesthandler.file import akka.actor._ -import org.enso.jsonrpc.Errors.ServiceError import org.enso.jsonrpc._ import org.enso.languageserver.filemanager.{ FileManagerProtocol, @@ -39,13 +38,13 @@ class ReadTextualFileHandler( ): Receive = { case Status.Failure(ex) => log.error(s"Failure during $ReadFile operation:", ex) - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.ServiceError) cancellable.cancel() context.stop(self) case RequestTimeout => log.error(s"Request $id timed out") - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.RequestTimeout) context.stop(self) case FileManagerProtocol.ReadTextualFileResult(Left(failure)) => diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/TreeFileHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/TreeFileHandler.scala index 586d2f12b29..92af1412052 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/TreeFileHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/TreeFileHandler.scala @@ -1,7 +1,6 @@ package org.enso.languageserver.requesthandler.file import akka.actor._ -import org.enso.jsonrpc.Errors.ServiceError import org.enso.jsonrpc._ import org.enso.languageserver.filemanager.{ FileManagerProtocol, @@ -37,13 +36,13 @@ class TreeFileHandler(requestTimeout: FiniteDuration, fileManager: ActorRef) ): Receive = { case Status.Failure(ex) => log.error(s"Failure during $TreeFile operation:", ex) - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.ServiceError) cancellable.cancel() context.stop(self) case RequestTimeout => log.error(s"Request $id timed out") - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.RequestTimeout) context.stop(self) case FileManagerProtocol.TreeFileResult(Left(failure)) => diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/WriteTextualFileHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/WriteTextualFileHandler.scala index 4f4edf3eec5..346b94ecae9 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/WriteTextualFileHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/file/WriteTextualFileHandler.scala @@ -1,7 +1,6 @@ package org.enso.languageserver.requesthandler.file import akka.actor._ -import org.enso.jsonrpc.Errors.ServiceError import org.enso.jsonrpc._ import org.enso.languageserver.filemanager.{ FileManagerProtocol, @@ -39,13 +38,13 @@ class WriteTextualFileHandler( ): Receive = { case Status.Failure(ex) => log.error(s"Failure during $WriteFile operation:", ex) - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.ServiceError) cancellable.cancel() context.stop(self) case RequestTimeout => log.error(s"Request $id timed out") - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.ServiceError) context.stop(self) case FileManagerProtocol.WriteFileResult(Left(failure)) => diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/refactoring/RenameProjectHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/refactoring/RenameProjectHandler.scala index 6d5e9b65af6..72aec6e39a3 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/refactoring/RenameProjectHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/refactoring/RenameProjectHandler.scala @@ -3,7 +3,6 @@ package org.enso.languageserver.requesthandler.refactoring import java.util.UUID import akka.actor.{Actor, ActorLogging, ActorRef, Cancellable, Props} -import org.enso.jsonrpc.Errors.ServiceError import org.enso.jsonrpc._ import org.enso.languageserver.refactoring.ProjectNameChangedEvent import org.enso.languageserver.refactoring.RefactoringApi.RenameProject @@ -51,7 +50,7 @@ class RenameProjectHandler(timeout: FiniteDuration, runtimeConnector: ActorRef) ): Receive = { case RequestTimeout => log.error(s"Request $id timed out") - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.RequestTimeout) context.stop(self) case Api.Response(_, Api.ProjectRenamed(_)) => diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/search/CompletionHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/search/CompletionHandler.scala index fe1088b5704..696fc94f0b5 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/search/CompletionHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/search/CompletionHandler.scala @@ -1,7 +1,6 @@ package org.enso.languageserver.requesthandler.search import akka.actor.{Actor, ActorLogging, ActorRef, Cancellable, Props, Status} -import org.enso.jsonrpc.Errors.ServiceError import org.enso.jsonrpc._ import org.enso.languageserver.requesthandler.RequestTimeout import org.enso.languageserver.search.SearchApi.{ @@ -60,7 +59,7 @@ class CompletionHandler( case RequestTimeout => log.error(s"Request $id timed out") - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.RequestTimeout) context.stop(self) case msg: SearchProtocol.SearchFailure => diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/search/GetSuggestionsDatabaseHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/search/GetSuggestionsDatabaseHandler.scala index cfe238ba646..05c37a7a387 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/search/GetSuggestionsDatabaseHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/search/GetSuggestionsDatabaseHandler.scala @@ -1,7 +1,6 @@ package org.enso.languageserver.requesthandler.search import akka.actor.{Actor, ActorLogging, ActorRef, Cancellable, Props, Status} -import org.enso.jsonrpc.Errors.ServiceError import org.enso.jsonrpc._ import org.enso.languageserver.requesthandler.RequestTimeout import org.enso.languageserver.search.SearchApi.{ @@ -50,7 +49,7 @@ class GetSuggestionsDatabaseHandler( case RequestTimeout => log.error(s"Request $id timed out") - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.RequestTimeout) context.stop(self) case msg: SearchProtocol.SearchFailure => diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/search/GetSuggestionsDatabaseVersionHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/search/GetSuggestionsDatabaseVersionHandler.scala index 985f6f71a1b..e4ea89782ec 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/search/GetSuggestionsDatabaseVersionHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/search/GetSuggestionsDatabaseVersionHandler.scala @@ -1,7 +1,6 @@ package org.enso.languageserver.requesthandler.search import akka.actor.{Actor, ActorLogging, ActorRef, Cancellable, Props, Status} -import org.enso.jsonrpc.Errors.ServiceError import org.enso.jsonrpc._ import org.enso.languageserver.requesthandler.RequestTimeout import org.enso.languageserver.search.SearchApi.{ @@ -50,7 +49,7 @@ class GetSuggestionsDatabaseVersionHandler( case RequestTimeout => log.error(s"Request $id timed out") - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.RequestTimeout) context.stop(self) case msg: SearchProtocol.SearchFailure => diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/search/ImportHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/search/ImportHandler.scala index 8e2d6e88431..25a93c9b3ea 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/search/ImportHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/search/ImportHandler.scala @@ -1,7 +1,6 @@ package org.enso.languageserver.requesthandler.search import akka.actor.{Actor, ActorLogging, ActorRef, Cancellable, Props, Status} -import org.enso.jsonrpc.Errors.ServiceError import org.enso.jsonrpc._ import org.enso.languageserver.requesthandler.RequestTimeout import org.enso.languageserver.search.SearchApi.{ @@ -50,7 +49,7 @@ class ImportHandler( case RequestTimeout => log.error(s"Request $id timed out") - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.RequestTimeout) context.stop(self) case msg: SearchProtocol.SearchFailure => diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/search/InvalidateSuggestionsDatabaseHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/search/InvalidateSuggestionsDatabaseHandler.scala index 027cdd5bbe4..419d16f416e 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/search/InvalidateSuggestionsDatabaseHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/search/InvalidateSuggestionsDatabaseHandler.scala @@ -1,7 +1,6 @@ package org.enso.languageserver.requesthandler.search import akka.actor.{Actor, ActorLogging, ActorRef, Cancellable, Props, Status} -import org.enso.jsonrpc.Errors.ServiceError import org.enso.jsonrpc._ import org.enso.languageserver.requesthandler.RequestTimeout import org.enso.languageserver.runtime.{ @@ -54,7 +53,7 @@ class InvalidateSuggestionsDatabaseHandler( case RequestTimeout => log.error(s"Request $id timed out") - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.RequestTimeout) context.stop(self) case msg: SearchProtocol.SearchFailure => diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/session/InitProtocolConnectionHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/session/InitProtocolConnectionHandler.scala index b15c5fd81a9..35d33d12916 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/session/InitProtocolConnectionHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/session/InitProtocolConnectionHandler.scala @@ -1,8 +1,7 @@ package org.enso.languageserver.requesthandler.session import akka.actor.{Actor, ActorLogging, ActorRef, Cancellable, Props} -import org.enso.jsonrpc.Errors.ServiceError -import org.enso.jsonrpc.{Id, Request, ResponseError, ResponseResult} +import org.enso.jsonrpc.{Errors, Id, Request, ResponseError, ResponseResult} import org.enso.languageserver.filemanager.FileManagerProtocol import org.enso.languageserver.filemanager.FileManagerProtocol.ContentRootsResult import org.enso.languageserver.requesthandler.RequestTimeout @@ -42,7 +41,7 @@ class InitProtocolConnectionHandler( ): Receive = { case RequestTimeout => log.error(s"Getting content roots timed out") - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.RequestTimeout) context.stop(self) case ContentRootsResult(contentRoots) => diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/text/ApplyEditHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/text/ApplyEditHandler.scala index c583519e2c7..3e8c3501e66 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/text/ApplyEditHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/text/ApplyEditHandler.scala @@ -1,7 +1,6 @@ package org.enso.languageserver.requesthandler.text import akka.actor.{Actor, ActorLogging, ActorRef, Cancellable, Props} -import org.enso.jsonrpc.Errors.ServiceError import org.enso.jsonrpc._ import org.enso.languageserver.requesthandler.RequestTimeout import org.enso.languageserver.session.JsonSession @@ -45,7 +44,7 @@ class ApplyEditHandler( ): Receive = { case RequestTimeout => log.error(s"Applying edit for ${rpcSession.clientId} timed out") - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.RequestTimeout) context.stop(self) case ApplyEditSuccess => diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/text/CloseFileHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/text/CloseFileHandler.scala index 71fd469b703..74c0dc0ad66 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/text/CloseFileHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/text/CloseFileHandler.scala @@ -1,7 +1,6 @@ package org.enso.languageserver.requesthandler.text import akka.actor.{Actor, ActorLogging, ActorRef, Cancellable, Props} -import org.enso.jsonrpc.Errors.ServiceError import org.enso.jsonrpc._ import org.enso.languageserver.requesthandler.RequestTimeout import org.enso.languageserver.session.JsonSession @@ -45,7 +44,7 @@ class CloseFileHandler( ): Receive = { case RequestTimeout => log.error(s"Closing file for ${rpcSession.clientId} timed out") - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.RequestTimeout) context.stop(self) case FileClosed => diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/text/OpenFileHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/text/OpenFileHandler.scala index 8d3503c3e66..d0a44afc4e3 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/text/OpenFileHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/text/OpenFileHandler.scala @@ -1,8 +1,7 @@ package org.enso.languageserver.requesthandler.text import akka.actor.{Actor, ActorLogging, ActorRef, Cancellable, Props} -import org.enso.jsonrpc.Errors.ServiceError -import org.enso.jsonrpc.{Id, Request, ResponseError, ResponseResult} +import org.enso.jsonrpc.{Errors, Id, Request, ResponseError, ResponseResult} import org.enso.languageserver.filemanager.FileSystemFailureMapper import org.enso.languageserver.requesthandler.RequestTimeout import org.enso.languageserver.session.JsonSession @@ -49,7 +48,7 @@ class OpenFileHandler( ): Receive = { case RequestTimeout => log.error(s"Opening file for ${rpcSession.clientId} timed out") - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.RequestTimeout) context.stop(self) case OpenFileResponse(Right(OpenFileResult(buffer, capability))) => diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/text/SaveFileHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/text/SaveFileHandler.scala index 08e191b2cbe..43c139bf965 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/text/SaveFileHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/text/SaveFileHandler.scala @@ -1,7 +1,6 @@ package org.enso.languageserver.requesthandler.text import akka.actor.{Actor, ActorLogging, ActorRef, Cancellable, Props} -import org.enso.jsonrpc.Errors.ServiceError import org.enso.jsonrpc._ import org.enso.languageserver.filemanager.FileSystemFailureMapper import org.enso.languageserver.requesthandler.RequestTimeout @@ -55,7 +54,7 @@ class SaveFileHandler( ): Receive = { case RequestTimeout => log.error(s"Saving file for ${rpcSession.clientId} timed out") - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.RequestTimeout) context.stop(self) case FileSaved => diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/visualisation/AttachVisualisationHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/visualisation/AttachVisualisationHandler.scala index 65dcd392acf..f7e64a3089e 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/visualisation/AttachVisualisationHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/visualisation/AttachVisualisationHandler.scala @@ -1,7 +1,6 @@ package org.enso.languageserver.requesthandler.visualisation import akka.actor.{Actor, ActorLogging, ActorRef, Cancellable, Props} -import org.enso.jsonrpc.Errors.ServiceError import org.enso.jsonrpc._ import org.enso.languageserver.data.ClientId import org.enso.languageserver.requesthandler.RequestTimeout @@ -52,7 +51,7 @@ class AttachVisualisationHandler( ): Receive = { case RequestTimeout => log.error(s"Request $id timed out") - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.RequestTimeout) context.stop(self) case ContextRegistryProtocol.VisualisationAttached => diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/visualisation/DetachVisualisationHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/visualisation/DetachVisualisationHandler.scala index 85a350e1da1..196ab8af711 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/visualisation/DetachVisualisationHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/visualisation/DetachVisualisationHandler.scala @@ -1,7 +1,6 @@ package org.enso.languageserver.requesthandler.visualisation import akka.actor.{Actor, ActorLogging, ActorRef, Cancellable, Props} -import org.enso.jsonrpc.Errors.ServiceError import org.enso.jsonrpc._ import org.enso.languageserver.data.ClientId import org.enso.languageserver.requesthandler.RequestTimeout @@ -52,7 +51,7 @@ class DetachVisualisationHandler( ): Receive = { case RequestTimeout => log.error(s"Request $id timed out") - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.RequestTimeout) context.stop(self) case ContextRegistryProtocol.VisualisationDetached => diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/visualisation/ModifyVisualisationHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/visualisation/ModifyVisualisationHandler.scala index cf922cd77a1..72fe52ae32d 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/visualisation/ModifyVisualisationHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/requesthandler/visualisation/ModifyVisualisationHandler.scala @@ -1,7 +1,6 @@ package org.enso.languageserver.requesthandler.visualisation import akka.actor.{Actor, ActorLogging, ActorRef, Cancellable, Props} -import org.enso.jsonrpc.Errors.ServiceError import org.enso.jsonrpc._ import org.enso.languageserver.data.ClientId import org.enso.languageserver.requesthandler.RequestTimeout @@ -51,7 +50,7 @@ class ModifyVisualisationHandler( ): Receive = { case RequestTimeout => log.error(s"Request $id timed out") - replyTo ! ResponseError(Some(id), ServiceError) + replyTo ! ResponseError(Some(id), Errors.RequestTimeout) context.stop(self) case ContextRegistryProtocol.VisualisationModified => diff --git a/lib/scala/json-rpc-server/src/main/scala/org/enso/jsonrpc/Protocol.scala b/lib/scala/json-rpc-server/src/main/scala/org/enso/jsonrpc/Protocol.scala index c3f3ea15678..39332b26262 100644 --- a/lib/scala/json-rpc-server/src/main/scala/org/enso/jsonrpc/Protocol.scala +++ b/lib/scala/json-rpc-server/src/main/scala/org/enso/jsonrpc/Protocol.scala @@ -109,6 +109,7 @@ object Errors { case object ServiceError extends Error(1, "Service error") case object NotImplementedError extends Error(10, "The requested method is not implemented") + case object RequestTimeout extends Error(11, "Request timeout") case class UnknownError( override val code: Int, override val message: String,