mirror of
https://github.com/neovim/neovim.git
synced 2025-12-15 19:05:40 +00:00
feat(lua): improve error message to make it actionable (#13276)
* improve error message to make it actionable
This commit is contained in:
@@ -57,7 +57,7 @@ describe('API: highlight',function()
|
||||
-- Test nil argument.
|
||||
err, emsg = pcall(meths.get_hl_by_id, { nil }, false)
|
||||
eq(false, err)
|
||||
eq('Wrong type for argument 1, expecting Integer',
|
||||
eq('Wrong type for argument 1 when calling nvim_get_hl_by_id, expecting Integer',
|
||||
string.match(emsg, 'Wrong.*'))
|
||||
|
||||
-- Test 0 argument.
|
||||
@@ -112,7 +112,7 @@ describe('API: highlight',function()
|
||||
-- Test nil argument.
|
||||
err, emsg = pcall(meths.get_hl_by_name , { nil }, false)
|
||||
eq(false, err)
|
||||
eq('Wrong type for argument 1, expecting String',
|
||||
eq('Wrong type for argument 1 when calling nvim_get_hl_by_name, expecting String',
|
||||
string.match(emsg, 'Wrong.*'))
|
||||
|
||||
-- Test empty string argument.
|
||||
|
||||
@@ -751,7 +751,7 @@ describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function()
|
||||
end
|
||||
|
||||
it('rejects negative bufnr values', function()
|
||||
eq('Wrong type for argument 1, expecting Buffer',
|
||||
eq('Wrong type for argument 1 when calling nvim_buf_set_keymap, expecting Buffer',
|
||||
pcall_err(bufmeths.set_keymap, -1, '', 'lhs', 'rhs', {}))
|
||||
end)
|
||||
|
||||
|
||||
@@ -1350,7 +1350,7 @@ describe('API', function()
|
||||
eq({info=info}, meths.get_var("info_event"))
|
||||
eq({[1]=testinfo,[2]=stderr,[3]=info}, meths.list_chans())
|
||||
|
||||
eq("Vim:Error invoking 'nvim_set_current_buf' on channel 3 (amazing-cat):\nWrong type for argument 1, expecting Buffer",
|
||||
eq("Vim:Error invoking 'nvim_set_current_buf' on channel 3 (amazing-cat):\nWrong type for argument 1 when calling nvim_set_current_buf, expecting Buffer",
|
||||
pcall_err(eval, 'rpcrequest(3, "nvim_set_current_buf", -1)'))
|
||||
end)
|
||||
|
||||
@@ -1512,7 +1512,7 @@ describe('API', function()
|
||||
it("does not leak memory on incorrect argument types", function()
|
||||
local status, err = pcall(nvim, 'set_current_dir',{'not', 'a', 'dir'})
|
||||
eq(false, status)
|
||||
ok(err:match(': Wrong type for argument 1, expecting String') ~= nil)
|
||||
ok(err:match(': Wrong type for argument 1 when calling nvim_set_current_dir, expecting String') ~= nil)
|
||||
end)
|
||||
|
||||
describe('nvim_parse_expression', function()
|
||||
|
||||
Reference in New Issue
Block a user