aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/vim.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/api/vim.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/api/vim.c')
-rw-r--r--src/nvim/api/vim.c54
1 files changed, 28 insertions, 26 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index e5ef4a35c1..da00fbc6e3 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -165,8 +165,8 @@ String nvim_command_output(String str, Error *err)
nvim_command(str, err);
do_cmdline_cmd("redir END");
- if (err->set) {
- return (String) STRING_INIT;
+ if (ERROR_SET(err)) {
+ return (String)STRING_INIT;
}
return cstr_to_string((char *)get_vim_var_str(VV_COMMAND_OUTPUT));
@@ -188,7 +188,7 @@ Object nvim_eval(String expr, Error *err)
typval_T rettv;
if (eval0((char_u *)expr.data, &rettv, NULL, true) == FAIL) {
- api_set_error(err, Exception, "Failed to evaluate expression");
+ api_set_error(err, kErrorTypeException, "Failed to evaluate expression");
}
if (!try_end(err)) {
@@ -214,8 +214,8 @@ Object nvim_call_function(String fname, Array args, Error *err)
{
Object rv = OBJECT_INIT;
if (args.size > MAX_FUNC_ARGS) {
- api_set_error(err, Validation,
- _("Function called with too many arguments."));
+ api_set_error(err, kErrorTypeValidation,
+ "Function called with too many arguments.");
return rv;
}
@@ -237,7 +237,7 @@ Object nvim_call_function(String fname, Array args, Error *err)
curwin->w_cursor.lnum, curwin->w_cursor.lnum, &dummy,
true, NULL, NULL);
if (r == FAIL) {
- api_set_error(err, Exception, _("Error calling function."));
+ api_set_error(err, kErrorTypeException, "Error calling function.");
}
if (!try_end(err)) {
rv = vim_to_object(&rettv);
@@ -262,7 +262,7 @@ Integer nvim_strwidth(String str, Error *err)
FUNC_API_SINCE(1)
{
if (str.size > INT_MAX) {
- api_set_error(err, Validation, _("String length is too high"));
+ api_set_error(err, kErrorTypeValidation, "String length is too high");
return 0;
}
@@ -318,7 +318,7 @@ void nvim_set_current_dir(String dir, Error *err)
FUNC_API_SINCE(1)
{
if (dir.size >= MAXPATHL) {
- api_set_error(err, Validation, _("Directory string is too long"));
+ api_set_error(err, kErrorTypeValidation, "Directory string is too long");
return;
}
@@ -330,7 +330,7 @@ void nvim_set_current_dir(String dir, Error *err)
if (vim_chdir((char_u *)string, kCdScopeGlobal)) {
if (!try_end(err)) {
- api_set_error(err, Exception, _("Failed to change directory"));
+ api_set_error(err, kErrorTypeException, "Failed to change directory");
}
return;
}
@@ -539,8 +539,8 @@ void nvim_set_current_buf(Buffer buffer, Error *err)
int result = do_buffer(DOBUF_GOTO, DOBUF_FIRST, FORWARD, buf->b_fnum, 0);
if (!try_end(err) && result == FAIL) {
api_set_error(err,
- Exception,
- _("Failed to switch to buffer %d"),
+ kErrorTypeException,
+ "Failed to switch to buffer %d",
buffer);
}
}
@@ -592,8 +592,8 @@ void nvim_set_current_win(Window window, Error *err)
goto_tabpage_win(win_find_tabpage(win), win);
if (!try_end(err) && win != curwin) {
api_set_error(err,
- Exception,
- _("Failed to switch to window %d"),
+ kErrorTypeException,
+ "Failed to switch to window %d",
window);
}
}
@@ -646,8 +646,8 @@ void nvim_set_current_tabpage(Tabpage tabpage, Error *err)
goto_tabpage_tp(tp, true, true);
if (!try_end(err) && tp != curtab) {
api_set_error(err,
- Exception,
- _("Failed to switch to tabpage %d"),
+ kErrorTypeException,
+ "Failed to switch to tabpage %d",
tabpage);
}
}
@@ -745,30 +745,30 @@ Array nvim_call_atomic(uint64_t channel_id, Array calls, Error *err)
for (i = 0; i < calls.size; i++) {
if (calls.items[i].type != kObjectTypeArray) {
api_set_error(err,
- Validation,
- _("All items in calls array must be arrays"));
+ kErrorTypeValidation,
+ "All items in calls array must be arrays");
goto validation_error;
}
Array call = calls.items[i].data.array;
if (call.size != 2) {
api_set_error(err,
- Validation,
- _("All items in calls array must be arrays of size 2"));
+ kErrorTypeValidation,
+ "All items in calls array must be arrays of size 2");
goto validation_error;
}
if (call.items[0].type != kObjectTypeString) {
api_set_error(err,
- Validation,
- _("name must be String"));
+ kErrorTypeValidation,
+ "Name must be String");
goto validation_error;
}
String name = call.items[0].data.string;
if (call.items[1].type != kObjectTypeArray) {
api_set_error(err,
- Validation,
- _("args must be Array"));
+ kErrorTypeValidation,
+ "Args must be Array");
goto validation_error;
}
Array args = call.items[1].data.array;
@@ -776,7 +776,7 @@ Array nvim_call_atomic(uint64_t channel_id, Array calls, Error *err)
MsgpackRpcRequestHandler handler = msgpack_rpc_get_handler_for(name.data,
name.size);
Object result = handler.fn(channel_id, args, &nested_error);
- if (nested_error.set) {
+ if (ERROR_SET(&nested_error)) {
// error handled after loop
break;
}
@@ -785,7 +785,7 @@ Array nvim_call_atomic(uint64_t channel_id, Array calls, Error *err)
}
ADD(rv, ARRAY_OBJ(results));
- if (nested_error.set) {
+ if (ERROR_SET(&nested_error)) {
Array errval = ARRAY_DICT_INIT;
ADD(errval, INTEGER_OBJ((Integer)i));
ADD(errval, INTEGER_OBJ(nested_error.type));
@@ -794,10 +794,12 @@ Array nvim_call_atomic(uint64_t channel_id, Array calls, Error *err)
} else {
ADD(rv, NIL);
}
- return rv;
+ goto theend;
validation_error:
api_free_array(results);
+theend:
+ api_clear_error(&nested_error);
return rv;
}