vim-denops / denops.vim

🐜 An ecosystem of Vim/Neovim which allows developers to write cross-platform plugins in Deno

Home Page:https://vim-denops.github.io/denops-documentation/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error message is unfriendly when return value serialization failed

Milly opened this issue · comments

commented

Error message is unfriendly when return value serialization failed.

I'm testing in Vim8.2.

These error message is shown when denops.call(...) called.

[denops] Error: Failed to call 'getFoo' with [1]: Error: Failed to call 'call' with ["getbufvar",1,"foo"]: Error: Failed to call 'getbufvar(1, foo)': R

The part of message Error: ...: R, what is R?

If the problem point is Vim's channel implementation, it may be difficult to fix this in denops.vim.

Reproduction

Testing environment:

  • Windows 10
  • Vim 8.2.4732
" vimrc
set nocompatible
language C
" set runtimepath=...

function! Ok() abort
  let b:foo = {'bar': 1}
  call denops#notify('mytest', 'getFoo', [bufnr()])
endfunction

function! FailOnReturn() abort
  let b:foo = {'bar': {-> 1}}
  call denops#notify('mytest', 'getFoo', [bufnr()])
endfunction
// denops/mytest/main.ts
export type { Denops } from "https://deno.land/x/denops_std@v3.3.0/mod.ts";

export function main(denops: Denops) {
  denops.dispatcher = {
    async getFoo(bufNr: unknown): Promise<void> {
      await denops.call('getbufvar', bufNr, 'foo');
    },
  };
}
  1. Setup denops.vim in runtimepath.
  2. Run vim -u vimrc.
  3. Do :call OK(), then nothing.
  4. Do :call FailOnReturn(), then error message is shown.

Others

Full messages

[denops] Error: Failed to call 'getFoo' with [1]: Error: Failed to call 'call' with ["getbufvar",1,"foo"]: Error: Failed to call 'getbufvar(1, foo)': R
[denops]     at Vim.call (file:///tmp/denops.vim/denops/@denops-private/host/vim.ts:33:13)
[denops]     at async Service.call (file:///tmp/denops.vim/denops/@denops-private/service.ts:86:12)
[denops]     at async Session.call (file:///tmp/denops.vim/denops/@denops-private/service.ts:135:14)
[denops]     at async Session.dispatch (https://deno.land/x/msgpack_rpc@v3.1.4/session.ts:99:12)
[denops]     at async https://deno.land/x/msgpack_rpc@v3.1.4/session.ts:108:18
[denops]     at async Session.handleRequest (https://deno.land/x/msgpack_rpc@v3.1.4/session.ts:104:29)
[denops]     at Session.call (https://deno.land/x/msgpack_rpc@v3.1.4/session.ts:207:13)
[denops]     at async DenopsImpl.call (file:///tmp/denops.vim/denops/@denops/impl.ts:28:12)
[denops]     at async Session.getFoo (file:///tmp/denops-test/denops/mytest/main.ts:6:7)
[denops]     at async Session.dispatch (https://deno.land/x/msgpack_rpc@v3.1.4/session.ts:99:12)
[denops]     at async https://deno.land/x/msgpack_rpc@v3.1.4/session.ts:108:18
[denops]     at async Session.handleRequest (https://deno.land/x/msgpack_rpc@v3.1.4/session.ts:104:29)
[denops]     at Session.call (https://deno.land/x/msgpack_rpc@v3.1.4/session.ts:207:13)
[denops]     at async Service.dispatch (file:///tmp/denops.vim/denops/@denops-private/service.ts:101:14)
[denops]     at async dispatch (file:///tmp/denops.vim/denops/@denops-private/host/vim.ts:81:12)
[denops]     at async Session.<anonymous> (file:///tmp/denops.vim/denops/@denops-private/host/vim.ts:53:14)
commented

I tried to fix this in PR #186
How about it?