aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/vim.c
diff options
context:
space:
mode:
authorSander Bosma <sanderbosma@gmail.com>2017-03-01 10:43:47 +0100
committerJustin M. Keyes <justinkz@gmail.com>2017-04-23 23:44:29 +0200
commit5c9860a0a2bf27d409c986673f0a74542561c4c3 (patch)
tree72f53fdf36e2b627df51a4ee810987ff1a0dd477 /src/nvim/api/vim.c
parent45240538742d6276ab25abe0d8b02550e1c68179 (diff)
downloadrneovim-5c9860a0a2bf27d409c986673f0a74542561c4c3.tar.gz
rneovim-5c9860a0a2bf27d409c986673f0a74542561c4c3.tar.bz2
rneovim-5c9860a0a2bf27d409c986673f0a74542561c4c3.zip
api: Do not truncate errors <1 MB. #6237
Closes #5984
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r--src/nvim/api/vim.c44
1 files changed, 23 insertions, 21 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index e5ef4a35c1..bd4a196367 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -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,7 +214,7 @@ 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,
+ _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;
}
@@ -538,8 +538,8 @@ void nvim_set_current_buf(Buffer buffer, Error *err)
try_start();
int result = do_buffer(DOBUF_GOTO, DOBUF_FIRST, FORWARD, buf->b_fnum, 0);
if (!try_end(err) && result == FAIL) {
- api_set_error(err,
- Exception,
+ _api_set_error(err,
+ kErrorTypeException,
_("Failed to switch to buffer %d"),
buffer);
}
@@ -591,8 +591,8 @@ void nvim_set_current_win(Window window, Error *err)
try_start();
goto_tabpage_win(win_find_tabpage(win), win);
if (!try_end(err) && win != curwin) {
- api_set_error(err,
- Exception,
+ _api_set_error(err,
+ kErrorTypeException,
_("Failed to switch to window %d"),
window);
}
@@ -645,8 +645,8 @@ void nvim_set_current_tabpage(Tabpage tabpage, Error *err)
try_start();
goto_tabpage_tp(tp, true, true);
if (!try_end(err) && tp != curtab) {
- api_set_error(err,
- Exception,
+ _api_set_error(err,
+ kErrorTypeException,
_("Failed to switch to tabpage %d"),
tabpage);
}
@@ -744,30 +744,30 @@ Array nvim_call_atomic(uint64_t channel_id, Array calls, Error *err)
size_t i; // also used for freeing the variables
for (i = 0; i < calls.size; i++) {
if (calls.items[i].type != kObjectTypeArray) {
- api_set_error(err,
- Validation,
+ _api_set_error(err,
+ 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,
+ _api_set_error(err,
+ 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,
+ _api_set_error(err,
+ 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,
+ _api_set_error(err,
+ kErrorTypeValidation,
_("args must be Array"));
goto validation_error;
}
@@ -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_free_error(&nested_error);
return rv;
}