mirror of
https://github.com/neovim/neovim.git
synced 2025-10-10 03:46:31 +00:00
API: validation: mention invalid method name (#8489)
This commit is contained in:
@@ -29,6 +29,8 @@ static void msgpack_rpc_add_method_handler(String method,
|
||||
map_put(String, MsgpackRpcRequestHandler)(methods, method, handler);
|
||||
}
|
||||
|
||||
/// @param name API method name
|
||||
/// @param name_len name size (includes terminating NUL)
|
||||
MsgpackRpcRequestHandler msgpack_rpc_get_handler_for(const char *name,
|
||||
size_t name_len)
|
||||
{
|
||||
|
@@ -16,6 +16,7 @@
|
||||
#include "nvim/api/private/dispatch.h"
|
||||
#include "nvim/api/buffer.h"
|
||||
#include "nvim/msgpack_rpc/channel.h"
|
||||
#include "nvim/msgpack_rpc/helpers.h"
|
||||
#include "nvim/lua/executor.h"
|
||||
#include "nvim/vim.h"
|
||||
#include "nvim/buffer.h"
|
||||
@@ -1163,6 +1164,11 @@ Array nvim_call_atomic(uint64_t channel_id, Array calls, Error *err)
|
||||
|
||||
MsgpackRpcRequestHandler handler = msgpack_rpc_get_handler_for(name.data,
|
||||
name.size);
|
||||
if (handler.fn == msgpack_rpc_handle_missing_method) {
|
||||
api_set_error(&nested_error, kErrorTypeException, "Invalid method: %s",
|
||||
name.size > 0 ? name.data : "<empty>");
|
||||
break;
|
||||
}
|
||||
Object result = handler.fn(channel_id, args, &nested_error);
|
||||
if (ERROR_SET(&nested_error)) {
|
||||
// error handled after loop
|
||||
|
Reference in New Issue
Block a user