diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-04-13 02:13:29 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-04-13 17:07:58 +0200 |
commit | 7e1591e06ab85bf088c7482a15ad48fc58c1005d (patch) | |
tree | 5a1e8c7f87d11bd28598836c7a989186bd3e0746 /src/nvim/msgpack_rpc/channel.c | |
parent | d08692a8246039b938b5645a6c01b4ff7f51671e (diff) | |
download | rneovim-7e1591e06ab85bf088c7482a15ad48fc58c1005d.tar.gz rneovim-7e1591e06ab85bf088c7482a15ad48fc58c1005d.tar.bz2 rneovim-7e1591e06ab85bf088c7482a15ad48fc58c1005d.zip |
API: emit nvim_error_event on failed async request
We already do this for _invalid_ async requests #9300.
Now we also do it for failed invocation of valid requests.
Diffstat (limited to 'src/nvim/msgpack_rpc/channel.c')
-rw-r--r-- | src/nvim/msgpack_rpc/channel.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 4cde9d22a1..3438949e2d 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -348,28 +348,28 @@ static void handle_request(Channel *channel, msgpack_object *request) if (is_get_mode && !input_blocking()) { // Defer the event to a special queue used by os/input.c. #6247 - multiqueue_put(ch_before_blocking_events, response_event, 1, evdata); + multiqueue_put(ch_before_blocking_events, request_event, 1, evdata); } else { // Invoke immediately. - response_event((void **)&evdata); + request_event((void **)&evdata); } } else { - multiqueue_put(channel->events, response_event, 1, evdata); + multiqueue_put(channel->events, request_event, 1, evdata); DLOG("RPC: scheduled %.*s", method->via.bin.size, method->via.bin.ptr); } } -/// Responds to a message, depending on the type: -/// - Request: writes the response. -/// - Notification: does nothing. -static void response_event(void **argv) +/// Handles a message, depending on the type: +/// - Request: invokes method and writes the response (or error). +/// - Notification: invokes method (emits `nvim_error_event` on error). +static void request_event(void **argv) { RequestEvent *e = argv[0]; Channel *channel = e->channel; MsgpackRpcRequestHandler handler = e->handler; Error error = ERROR_INIT; Object result = handler.fn(channel->id, e->args, &error); - if (e->type == kMessageTypeRequest) { + if (e->type == kMessageTypeRequest || ERROR_SET(&error)) { // Send the response. msgpack_packer response; msgpack_packer_init(&response, &out_buffer, msgpack_sbuffer_write); |