patch 9.1.0984: exception handling can be improved
Problem: exception handling can be improved Solution: add v:stacktrace and getstacktrace() closes: #16360 Co-authored-by: Naruhiko Nishino <naru123456789@gmail.com> Signed-off-by: ichizok <gclient.gaap@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
fd771613b3
commit
663d18d610
@ -562,6 +562,10 @@ throw_exception(void *value, except_type_T type, char_u *cmdname)
|
||||
excp->throw_lnum = SOURCING_LNUM;
|
||||
}
|
||||
|
||||
excp->stacktrace = stacktrace_create();
|
||||
if (excp->stacktrace != NULL)
|
||||
excp->stacktrace->lv_refcount = 1;
|
||||
|
||||
if (p_verbose >= 13 || debug_break_level > 0)
|
||||
{
|
||||
int save_msg_silent = msg_silent;
|
||||
@ -647,6 +651,7 @@ discard_exception(except_T *excp, int was_finished)
|
||||
if (excp->type == ET_ERROR)
|
||||
free_msglist(excp->messages);
|
||||
vim_free(excp->throw_name);
|
||||
list_unref(excp->stacktrace);
|
||||
vim_free(excp);
|
||||
}
|
||||
|
||||
@ -671,6 +676,7 @@ catch_exception(except_T *excp)
|
||||
excp->caught = caught_stack;
|
||||
caught_stack = excp;
|
||||
set_vim_var_string(VV_EXCEPTION, (char_u *)excp->value, -1);
|
||||
set_vim_var_list(VV_STACKTRACE, excp->stacktrace);
|
||||
if (*excp->throw_name != NUL)
|
||||
{
|
||||
if (excp->throw_lnum != 0)
|
||||
@ -721,6 +727,7 @@ finish_exception(except_T *excp)
|
||||
if (caught_stack != NULL)
|
||||
{
|
||||
set_vim_var_string(VV_EXCEPTION, (char_u *)caught_stack->value, -1);
|
||||
set_vim_var_list(VV_STACKTRACE, caught_stack->stacktrace);
|
||||
if (*caught_stack->throw_name != NUL)
|
||||
{
|
||||
if (caught_stack->throw_lnum != 0)
|
||||
@ -741,6 +748,7 @@ finish_exception(except_T *excp)
|
||||
{
|
||||
set_vim_var_string(VV_EXCEPTION, NULL, -1);
|
||||
set_vim_var_string(VV_THROWPOINT, NULL, -1);
|
||||
set_vim_var_list(VV_STACKTRACE, NULL);
|
||||
}
|
||||
|
||||
// Discard the exception, but use the finish message for 'verbose'.
|
||||
|
||||
Reference in New Issue
Block a user