diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2018-05-07 03:24:01 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2018-05-09 23:18:38 +0200 |
commit | c9f3174075a7168f10fabf806891ef59ee3b13d4 (patch) | |
tree | 67adda606732fdcfa746852a685c183bc11037a1 /src/nvim/eval.c | |
parent | 33bfea31b0cd630f6494cf91d06c807f03d29a85 (diff) | |
download | rneovim-c9f3174075a7168f10fabf806891ef59ee3b13d4.tar.gz rneovim-c9f3174075a7168f10fabf806891ef59ee3b13d4.tar.bz2 rneovim-c9f3174075a7168f10fabf806891ef59ee3b13d4.zip |
API: return non-generic VimL errors
- Return VimL errors instead of generic errors for:
- nvim_call_function
- nvim_call_dict_function
- Fix tests which were silently broken before this change.
This violates #6150 where we agreed not to translate API errors. But
that can be fixed later.
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r-- | src/nvim/eval.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index cc29496968..3c408a4381 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -6241,20 +6241,21 @@ bool set_ref_in_func(char_u *name, ufunc_T *fp_in, int copyID) /// invoked function uses them. It is called like this: /// new_argcount = argv_func(current_argcount, argv, called_func_argcount) /// -/// Return FAIL when the function can't be called, OK otherwise. -/// Also returns OK when an error was encountered while executing the function. +/// @return FAIL if function cannot be called, else OK (even if an error +/// occurred while executing the function! Use `msg_first_ignored_err` +/// to get the error) int call_func( const char_u *funcname, // name of the function int len, // length of "name" - typval_T *rettv, // return value goes here + typval_T *rettv, // [out] value goes here int argcount_in, // number of "argvars" typval_T *argvars_in, // vars for arguments, must have "argcount" // PLUS ONE elements! ArgvFunc argv_func, // function to fill in argvars linenr_T firstline, // first line of range linenr_T lastline, // last line of range - int *doesrange, // return: function handled range + int *doesrange, // [out] function handled range bool evaluate, partial_T *partial, // optional, can be NULL dict_T *selfdict_in // Dictionary for "self" @@ -6428,21 +6429,25 @@ call_func( return ret; } -/* - * Give an error message with a function name. Handle <SNR> things. - * "ermsg" is to be passed without translation, use N_() instead of _(). - */ +/// Give an error message with a function name. Handle <SNR> things. +/// +/// @param ermsg must be passed without translation (use N_() instead of _()). +/// @param name function name static void emsg_funcname(char *ermsg, char_u *name) { - char_u *p; + char_u *p; - if (*name == K_SPECIAL) + if (*name == K_SPECIAL) { p = concat_str((char_u *)"<SNR>", name + 3); - else + } else { p = name; + } + EMSG2(_(ermsg), p); - if (p != name) + + if (p != name) { xfree(p); + } } /* |