You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Previously, if a user passed non compliant reply to a request, the
framework would raise and your server would crash.
Previously, if a client sent an invalid request or notification, the
framework would raise, not providing a good error for the user or the
LSP author.
Now, in those three cases, if the framework sees a non-compliant
response, it will respond to the client with a relevant error code and
message.
Note: in the case of notifications, we just log, as there is nothing to
respond to.
test"returns an internal error and logs when the reply to a request is invalid",%{
219
+
client: client
220
+
}do
221
+
id=System.unique_integer([:positive])
222
+
223
+
expected_msg=
224
+
~S'''
225
+
Invalid response for request textDocument/documentSymbol.
226
+
227
+
Response: [nil, []]
228
+
Errors: "expected either either a list of a %GenLSP.Structures.SymbolInformation{}, a list of a %GenLSP.Structures.DocumentSymbol{}, or null or a %GenLSP.ErrorResponse{}"
229
+
'''
230
+
231
+
assert:ok==
232
+
request(client,%{
233
+
"jsonrpc"=>"2.0",
234
+
"method"=>"initialize",
235
+
"params"=>%{"capabilities"=>%{}},
236
+
"id"=>id
237
+
})
238
+
239
+
log=
240
+
capture_log(fn->
241
+
assert:ok==
242
+
request(client,%{
243
+
"jsonrpc"=>"2.0",
244
+
"method"=>"textDocument/documentSymbol",
245
+
"params"=>%{"textDocument"=>%{"uri"=>"foo"}},
246
+
"id"=>2
247
+
})
248
+
249
+
assert_error2,
250
+
%{
251
+
"message"=>msg,
252
+
"code"=>-32603
253
+
},
254
+
500
255
+
256
+
assertmsg=~expected_msg
257
+
end)
258
+
259
+
assertlog=~expected_msg
260
+
end
261
+
262
+
test"returns an invalid request when the paylaod is not parseable, but is still deemed a request",
0 commit comments