Skip to content

Commit e136c53

Browse files
committed
Enable handling of requests with no parameters.
An example of this is the "shutdown" request. It has no parameters (parameter type is void), and so this was failing with a swallowed exception. Also, log the exception so if there turn out to be any other edge cases they'll be easier to diagnose.
1 parent 1158fd8 commit e136c53

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Server/LspRequestRouter.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,12 @@ public async Task<ErrorResponse> RouteRequest(IHandlerDescriptor descriptor, Req
121121
object @params;
122122
try
123123
{
124-
@params = request.Params.ToObject(descriptor.Params, _serializer.JsonSerializer);
124+
@params = request.Params?.ToObject(descriptor.Params, _serializer.JsonSerializer);
125125
}
126-
catch
126+
catch (Exception cannotDeserializeRequestParams)
127127
{
128+
_logger.LogError(new EventId(-32602), cannotDeserializeRequestParams, "Failed to deserialise request parameters.");
129+
128130
return new InvalidParams(request.Id);
129131
}
130132

0 commit comments

Comments
 (0)