aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/msgpack_rpc/channel.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-04-24 02:14:14 +0200
committerGitHub <noreply@github.com>2017-04-24 02:14:14 +0200
commit7f6d3d305269fd1139bc2aec9a91bf98ad595199 (patch)
tree965d18fb11d25959e709a18d1c9d1fca0c4df432 /src/nvim/msgpack_rpc/channel.c
parent1fe8945748620713402cab77a46501ec5311778b (diff)
parent086c354a0aad2769042dc91bf5bad021109f56e4 (diff)
downloadrneovim-7f6d3d305269fd1139bc2aec9a91bf98ad595199.tar.gz
rneovim-7f6d3d305269fd1139bc2aec9a91bf98ad595199.tar.bz2
rneovim-7f6d3d305269fd1139bc2aec9a91bf98ad595199.zip
Merge #6569 from justinmk/apierror
api: Do not truncate errors <1 MB
Diffstat (limited to 'src/nvim/msgpack_rpc/channel.c')
-rw-r--r--src/nvim/msgpack_rpc/channel.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c
index b2c6ef852c..59594357de 100644
--- a/src/nvim/msgpack_rpc/channel.c
+++ b/src/nvim/msgpack_rpc/channel.c
@@ -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, Exception, _("Invalid channel \"%" PRIu64 "\""), id);
+ api_set_error(err, kErrorTypeException, "Invalid channel: %" PRIu64, id);
api_free_array(args);
return NIL;
}
@@ -212,7 +212,8 @@ Object channel_send_call(uint64_t id,
if (frame.errored) {
if (frame.result.type == kObjectTypeString) {
- api_set_error(err, Exception, "%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,14 +221,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) {
- err->type = (ErrorType) array.items[0].data.integer;
- xstrlcpy(err->msg, array.items[1].data.string.data, sizeof(err->msg));
- err->set = true;
+ api_set_error(err, (ErrorType)array.items[0].data.integer, "%s",
+ array.items[1].data.string.data);
} else {
- api_set_error(err, Exception, "%s", "unknown error");
+ api_set_error(err, kErrorTypeException, "%s", "unknown error");
}
} else {
- api_set_error(err, Exception, "%s", "unknown error");
+ api_set_error(err, kErrorTypeException, "%s", "unknown error");
}
api_free_object(frame.result);
@@ -398,7 +398,7 @@ static void handle_request(Channel *channel, msgpack_object *request)
Error error = ERROR_INIT;
msgpack_rpc_validate(&request_id, request, &error);
- if (error.set) {
+ if (ERROR_SET(&error)) {
// Validation failed, send response with error
if (channel_write(channel,
serialize_response(channel->id,
@@ -412,9 +412,9 @@ static void handle_request(Channel *channel, msgpack_object *request)
channel->id);
call_set_error(channel, buf);
}
+ api_clear_error(&error);
return;
}
-
// Retrieve the request handler
MsgpackRpcRequestHandler handler;
msgpack_object *method = msgpack_rpc_method(request);
@@ -470,6 +470,7 @@ static void on_request_event(void **argv)
api_free_array(args);
decref(channel);
xfree(e);
+ api_clear_error(&error);
}
static bool channel_write(Channel *channel, WBuffer *buffer)
@@ -512,12 +513,13 @@ 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, Exception, "%s", err);
+ api_set_error(&e, kErrorTypeException, "%s", err);
channel_write(channel, serialize_response(channel->id,
id,
&e,
NIL,
&out_buffer));
+ api_clear_error(&e);
}
static void send_request(Channel *channel,