mirror of
https://github.com/neovim/neovim.git
synced 2025-10-07 10:26:31 +00:00
api_set_error(): rename
This commit is contained in:
@@ -192,7 +192,7 @@ Object channel_send_call(uint64_t id,
|
||||
Channel *channel = NULL;
|
||||
|
||||
if (!(channel = pmap_get(uint64_t)(channels, id)) || channel->closed) {
|
||||
_api_set_error(err, kErrorTypeException, _("Invalid channel \"%" PRIu64 "\""), id);
|
||||
api_set_error(err, kErrorTypeException, _("Invalid channel \"%" PRIu64 "\""), id);
|
||||
api_free_array(args);
|
||||
return NIL;
|
||||
}
|
||||
@@ -212,7 +212,7 @@ Object channel_send_call(uint64_t id,
|
||||
|
||||
if (frame.errored) {
|
||||
if (frame.result.type == kObjectTypeString) {
|
||||
_api_set_error(err, kErrorTypeException, "%s", frame.result.data.string.data);
|
||||
api_set_error(err, kErrorTypeException, "%s", frame.result.data.string.data);
|
||||
} else if (frame.result.type == kObjectTypeArray) {
|
||||
// Should be an error in the form [type, message]
|
||||
Array array = frame.result.data.array;
|
||||
@@ -220,13 +220,13 @@ Object channel_send_call(uint64_t id,
|
||||
&& (array.items[0].data.integer == kErrorTypeException
|
||||
|| array.items[0].data.integer == kErrorTypeValidation)
|
||||
&& array.items[1].type == kObjectTypeString) {
|
||||
_api_set_error(err, (ErrorType)array.items[0].data.integer, "%s",
|
||||
api_set_error(err, (ErrorType)array.items[0].data.integer, "%s",
|
||||
array.items[1].data.string.data);
|
||||
} else {
|
||||
_api_set_error(err, kErrorTypeException, "%s", "unknown error");
|
||||
api_set_error(err, kErrorTypeException, "%s", "unknown error");
|
||||
}
|
||||
} else {
|
||||
_api_set_error(err, kErrorTypeException, "%s", "unknown error");
|
||||
api_set_error(err, kErrorTypeException, "%s", "unknown error");
|
||||
}
|
||||
|
||||
api_free_object(frame.result);
|
||||
@@ -512,7 +512,7 @@ static bool channel_write(Channel *channel, WBuffer *buffer)
|
||||
static void send_error(Channel *channel, uint64_t id, char *err)
|
||||
{
|
||||
Error e = ERROR_INIT;
|
||||
_api_set_error(&e, kErrorTypeException, "%s", err);
|
||||
api_set_error(&e, kErrorTypeException, "%s", err);
|
||||
channel_write(channel, serialize_response(channel->id,
|
||||
id,
|
||||
&e,
|
||||
|
@@ -475,7 +475,7 @@ Object msgpack_rpc_handle_missing_method(uint64_t channel_id,
|
||||
Array args,
|
||||
Error *error)
|
||||
{
|
||||
_api_set_error(error, kErrorTypeException, "Invalid method name");
|
||||
api_set_error(error, kErrorTypeException, "Invalid method name");
|
||||
return NIL;
|
||||
}
|
||||
|
||||
@@ -484,7 +484,7 @@ Object msgpack_rpc_handle_invalid_arguments(uint64_t channel_id,
|
||||
Array args,
|
||||
Error *error)
|
||||
{
|
||||
_api_set_error(error, kErrorTypeException, "Invalid method arguments");
|
||||
api_set_error(error, kErrorTypeException, "Invalid method arguments");
|
||||
return NIL;
|
||||
}
|
||||
|
||||
@@ -570,29 +570,29 @@ void msgpack_rpc_validate(uint64_t *response_id,
|
||||
*response_id = NO_RESPONSE;
|
||||
// Validate the basic structure of the msgpack-rpc payload
|
||||
if (req->type != MSGPACK_OBJECT_ARRAY) {
|
||||
_api_set_error(err, kErrorTypeValidation, _("Message is not an array"));
|
||||
api_set_error(err, kErrorTypeValidation, _("Message is not an array"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (req->via.array.size == 0) {
|
||||
_api_set_error(err, kErrorTypeValidation, _("Message is empty"));
|
||||
api_set_error(err, kErrorTypeValidation, _("Message is empty"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (req->via.array.ptr[0].type != MSGPACK_OBJECT_POSITIVE_INTEGER) {
|
||||
_api_set_error(err, kErrorTypeValidation, _("Message type must be an integer"));
|
||||
api_set_error(err, kErrorTypeValidation, _("Message type must be an integer"));
|
||||
return;
|
||||
}
|
||||
|
||||
uint64_t type = req->via.array.ptr[0].via.u64;
|
||||
if (type != kMessageTypeRequest && type != kMessageTypeNotification) {
|
||||
_api_set_error(err, kErrorTypeValidation, _("Unknown message type"));
|
||||
api_set_error(err, kErrorTypeValidation, _("Unknown message type"));
|
||||
return;
|
||||
}
|
||||
|
||||
if ((type == kMessageTypeRequest && req->via.array.size != 4)
|
||||
|| (type == kMessageTypeNotification && req->via.array.size != 3)) {
|
||||
_api_set_error(err, kErrorTypeValidation, _("Request array size should be 4 (request) "
|
||||
api_set_error(err, kErrorTypeValidation, _("Request array size should be 4 (request) "
|
||||
"or 3 (notification)"));
|
||||
return;
|
||||
}
|
||||
@@ -600,19 +600,19 @@ void msgpack_rpc_validate(uint64_t *response_id,
|
||||
if (type == kMessageTypeRequest) {
|
||||
msgpack_object *id_obj = msgpack_rpc_msg_id(req);
|
||||
if (!id_obj) {
|
||||
_api_set_error(err, kErrorTypeValidation, _("ID must be a positive integer"));
|
||||
api_set_error(err, kErrorTypeValidation, _("ID must be a positive integer"));
|
||||
return;
|
||||
}
|
||||
*response_id = id_obj->via.u64;
|
||||
}
|
||||
|
||||
if (!msgpack_rpc_method(req)) {
|
||||
_api_set_error(err, kErrorTypeValidation, _("Method must be a string"));
|
||||
api_set_error(err, kErrorTypeValidation, _("Method must be a string"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!msgpack_rpc_args(req)) {
|
||||
_api_set_error(err, kErrorTypeValidation, _("Parameters must be an array"));
|
||||
api_set_error(err, kErrorTypeValidation, _("Parameters must be an array"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user