diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval.c | 24 | ||||
-rw-r--r-- | src/nvim/globals.h | 5 | ||||
-rw-r--r-- | src/nvim/lua/executor.c | 1 | ||||
-rw-r--r-- | src/nvim/msgpack_rpc/channel.c | 16 |
4 files changed, 42 insertions, 4 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 12e309bfdc..58285a7716 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -6529,7 +6529,7 @@ static void api_wrapper(typval_T *argvars, typval_T *rettv, FunPtr fptr) Object result = fn(VIML_INTERNAL_CALL, args, &err); if (ERROR_SET(&err)) { - nvim_err_writeln(cstr_as_string(err.msg)); + emsgf_multiline((const char *)e_api_error, err.msg); goto end; } @@ -14118,8 +14118,11 @@ static void f_rpcrequest(typval_T *argvars, typval_T *rettv, FunPtr fptr) Error err = ERROR_INIT; - Object result = rpc_send_call((uint64_t)argvars[0].vval.v_number, - tv_get_string(&argvars[1]), args, &err); + + uint64_t chan_id = (uint64_t)argvars[0].vval.v_number; + const char *method = tv_get_string(&argvars[1]); + + Object result = rpc_send_call(chan_id, method, args, &err); if (l_provider_call_nesting) { current_SID = save_current_SID; @@ -14132,7 +14135,20 @@ static void f_rpcrequest(typval_T *argvars, typval_T *rettv, FunPtr fptr) } if (ERROR_SET(&err)) { - nvim_err_writeln(cstr_as_string(err.msg)); + const char *name = NULL; + Channel *chan = find_channel(chan_id); + if (chan) { + name = rpc_client_name(chan); + } + msg_ext_set_kind("rpc_error"); + if (name) { + emsgf_multiline("Error invoking '%s' on channel %"PRIu64" (%s):\n%s", + method, chan_id, name, err.msg); + } else { + emsgf_multiline("Error invoking '%s' on channel %"PRIu64":\n%s", + method, chan_id, err.msg); + } + goto end; } diff --git a/src/nvim/globals.h b/src/nvim/globals.h index ec14ada3d2..9fa294ba87 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -1039,6 +1039,7 @@ EXTERN char_u e_au_recursive[] INIT(= N_( EXTERN char_u e_unsupportedoption[] INIT(= N_("E519: Option not supported")); EXTERN char_u e_fnametoolong[] INIT(= N_("E856: Filename too long")); EXTERN char_u e_float_as_string[] INIT(= N_("E806: using Float as a String")); + EXTERN char_u e_autocmd_err[] INIT(=N_( "E5500: autocmd has thrown an exception: %s")); EXTERN char_u e_cmdmap_err[] INIT(=N_( @@ -1047,6 +1048,10 @@ EXTERN char_u e_cmdmap_repeated[] INIT(=N_( "E5521: <Cmd> mapping must end with <CR> before second <Cmd>")); EXTERN char_u e_cmdmap_key[] INIT(=N_( "E5522: <Cmd> mapping must not include %s key")); + +EXTERN char_u e_api_error[] INIT(=N_( + "E5555: API call: %s")); + EXTERN char_u e_floatonly[] INIT(=N_( "E5601: Cannot close window, only floating window would remain")); EXTERN char_u e_floatexchange[] INIT(=N_( diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index 72b97736fc..4e94c10283 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -54,6 +54,7 @@ static void nlua_error(lua_State *const lstate, const char *const msg) size_t len; const char *const str = lua_tolstring(lstate, -1, &len); + msg_ext_set_kind("lua_error"); emsgf_multiline(msg, (int)len, str); lua_pop(lstate, 1); diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 3438949e2d..2f3af22b65 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -687,6 +687,22 @@ Dictionary rpc_client_info(Channel *chan) return copy_dictionary(chan->rpc.info); } +const char *rpc_client_name(Channel *chan) +{ + if (!chan->is_rpc) { + return NULL; + } + Dictionary info = chan->rpc.info; + for (size_t i = 0; i < info.size; i++) { + if (strequal("name", info.items[i].key.data) + && info.items[i].value.type == kObjectTypeString) { + return info.items[i].value.data.string.data; + } + } + + return NULL; +} + #if MIN_LOG_LEVEL <= DEBUG_LOG_LEVEL #define REQ "[request] " #define RES "[response] " |