RPC: turn errors from async calls into notifications

Previously, nvim sent a response with invalid request id (UINT64_MAX).
In functionaltests, catch unexpected error notifications in after_each().
This commit is contained in:
Björn Linse
2018-12-01 16:44:36 +01:00
parent 07ad5d71ab
commit 8b42249cdd
5 changed files with 45 additions and 3 deletions

View File

@@ -14,6 +14,7 @@ local ok, nvim_async, feed = helpers.ok, helpers.nvim_async, helpers.feed
local os_name = helpers.os_name
local request = helpers.request
local source = helpers.source
local next_msg = helpers.next_msg
local expect_err = global_helpers.expect_err
local format_string = global_helpers.format_string
@@ -46,6 +47,15 @@ describe('API', function()
request, nil)
end)
it('handles errors in async requests', function()
local error_types = meths.get_api_info()[2].error_types
nvim_async("bogus")
eq({'notification', 'nvim_error_event',
{error_types.Exception.id, 'Invalid method: nvim_bogus'}}, next_msg())
-- error didn't close channel.
eq(2, eval('1+1'))
end)
describe('nvim_command', function()
it('works', function()
local fname = helpers.tmpname()