Error handling when executing vim RPC.
@@ -38,6 +38,7 @@ function! s:HandleMessage(job, lines, event) abort
let l:id = get(l:message, 'id', v:null)
let l:method = get(l:message, 'method')
let l:params = get(l:message, 'params')
+ try
if l:method ==# 'execute'
for l:cmd in l:params
execute l:cmd
@@ -52,6 +53,21 @@ function! s:HandleMessage(job, lines, event) abort
\ "result": l:result,
\ }))
endif
+ catch /.*/
+ if l:id != v:null
+ call LanguageClient#Write(json_encode({
+ \ "jsonrpc": "2.0",
+ \ "id": l:id,
+ \ "error": {
+ \ "code": -32603,
+ \ "message": string(v:exception)
+ \ }
+ \ }))
+ endif
+ if $LANGUAGECLIENT_DEBUG
+ call s:Echoerr(string(v:exception))
+ endif
+ endtry
elseif has_key(l:message, 'result')
let l:id = get(l:message, 'id')
let l:result = get(l:message, 'result')
