diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2024-12-16 08:34:16 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-16 08:34:16 -0800 |
commit | 022449b5223659d515b78bada7de2fac8718820a (patch) | |
tree | 2ce4dd7b21d2ba4089308b877608f4dbc4166d99 /test/functional/lua | |
parent | fb8372adb3b9f50d4d18eba6f650c3728353ab00 (diff) | |
download | rneovim-022449b5223659d515b78bada7de2fac8718820a.tar.gz rneovim-022449b5223659d515b78bada7de2fac8718820a.tar.bz2 rneovim-022449b5223659d515b78bada7de2fac8718820a.zip |
fix(api): generic error messages, not using TRY_WRAP #31596
Problem:
- API functions using `try_start` directly, do not surface the
underlying error message, and instead show generic messages.
- Error-handling code is duplicated in the API impl.
- Failure modes are not tested.
Solution:
- Use `TRY_WRAP`.
- Add tests.
Diffstat (limited to 'test/functional/lua')
-rw-r--r-- | test/functional/lua/vim_spec.lua | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua index 3cfbfe167a..9e75861aa0 100644 --- a/test/functional/lua/vim_spec.lua +++ b/test/functional/lua/vim_spec.lua @@ -3955,6 +3955,17 @@ stack traceback: eq(win2, val) end) + it('failure modes', function() + matches( + 'nvim_exec2%(%): Vim:E492: Not an editor command: fooooo', + pcall_err(exec_lua, [[vim.api.nvim_win_call(0, function() vim.cmd 'fooooo' end)]]) + ) + eq( + 'Error executing lua: [string "<nvim>"]:0: fooooo', + pcall_err(exec_lua, [[vim.api.nvim_win_call(0, function() error('fooooo') end)]]) + ) + end) + it('does not cause ml_get errors with invalid visual selection', function() -- Add lines to the current buffer and make another window looking into an empty buffer. exec_lua [[ |