Better LSP error handling

This commit is contained in:
Martino Ferrari
2026-01-27 08:58:38 +01:00
parent aedc715ef3
commit 71a3c40108
5 changed files with 94 additions and 17 deletions

View File

@@ -222,6 +222,12 @@ func readMessage(reader *bufio.Reader) (*JsonRpcMessage, error) {
}
func HandleMessage(msg *JsonRpcMessage) {
defer func() {
if r := recover(); r != nil {
logger.Printf("Panic in HandleMessage: %v", r)
}
}()
switch msg.Method {
case "initialize":
var params InitializeParams
@@ -1326,10 +1332,10 @@ func HandleRename(params RenameParams) *WorkspaceEdit {
}
func respond(id any, result any) {
msg := JsonRpcMessage{
Jsonrpc: "2.0",
ID: id,
Result: result,
msg := map[string]any{
"jsonrpc": "2.0",
"id": id,
"result": result,
}
send(msg)
}