Skip to content

Commit

Permalink
Avoid server crash when handler returns LspResult.Error (#33)
Browse files Browse the repository at this point in the history
It appears that #29 broke the reporting of
LspResult.Error to StreamJsonRpc.

StreamJsonRpc processes LocalRpcException to report exceptions/errors from request handlers.
In particular we have code in `requestHandling` that actually throws LocalRcpException when
handler returns LspResult.Error.

This commit adds code to skip markingLocalRcpException as a fatal exception and make it not
crash the server.
  • Loading branch information
razzmatazz committed Aug 23, 2022
1 parent b145255 commit d9c3f48
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/LanguageServerProtocol.fs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ module Server =
// and thus any exception that happens during e.g. text sync gets swallowed.
use jsonRpc =
{ new JsonRpc(jsonRpcHandler) with
member this.IsFatalException(ex: Exception) = true }
member this.IsFatalException(ex: Exception) =
match ex with
| :? LocalRpcException -> false
| _ -> true
}

/// When the server wants to send a notification to the client
let sendServerNotification (rpcMethod: string) (notificationObj: obj) : AsyncLspResult<unit> =
Expand Down

0 comments on commit d9c3f48

Please sign in to comment.