aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerw7 <erw7.github@gmail.com>2022-11-05 19:40:02 +0900
committerzeertzjq <zeertzjq@outlook.com>2023-01-16 17:58:57 +0800
commitce66f158b55287924b33451b272de847ab75b332 (patch)
tree0e38d3bdb96527db820b18795c3b437a7885b6d2
parent307efe4906de9f0b7d8611ea36bddb85493c1447 (diff)
downloadrneovim-ce66f158b55287924b33451b272de847ab75b332.tar.gz
rneovim-ce66f158b55287924b33451b272de847ab75b332.tar.bz2
rneovim-ce66f158b55287924b33451b272de847ab75b332.zip
feat(api): show more exception info
-rw-r--r--src/nvim/api/private/helpers.c13
-rw-r--r--test/functional/autocmd/termxx_spec.lua2
2 files changed, 13 insertions, 2 deletions
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index bf19c8c395..519f2cc5bf 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -150,7 +150,18 @@ bool try_end(Error *err)
xfree(msg);
}
} else if (did_throw) {
- api_set_error(err, kErrorTypeException, "%s", current_exception->value);
+ if (*current_exception->throw_name != NUL) {
+ if (current_exception->throw_lnum != 0) {
+ api_set_error(err, kErrorTypeException, "%s, line %" PRIdLINENR ": %s",
+ current_exception->throw_name, current_exception->throw_lnum,
+ current_exception->value);
+ } else {
+ api_set_error(err, kErrorTypeException, "%s: %s",
+ current_exception->throw_name, current_exception->value);
+ }
+ } else {
+ api_set_error(err, kErrorTypeException, "%s", current_exception->value);
+ }
discard_current_exception();
}
diff --git a/test/functional/autocmd/termxx_spec.lua b/test/functional/autocmd/termxx_spec.lua
index 4717b1fa2e..0a33f1b2ac 100644
--- a/test/functional/autocmd/termxx_spec.lua
+++ b/test/functional/autocmd/termxx_spec.lua
@@ -24,7 +24,7 @@ describe('autocmd TermClose', function()
local function test_termclose_delete_own_buf()
command('autocmd TermClose * bdelete!')
command('terminal')
- matches('^Vim%(bdelete%):E937: Attempt to delete a buffer that is in use: term://',
+ matches('^TermClose Autocommands for "%*": Vim%(bdelete%):E937: Attempt to delete a buffer that is in use: term://',
pcall_err(command, 'bdelete!'))
assert_alive()
end