aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/api/vim.c10
-rw-r--r--src/nvim/eval.c12
-rw-r--r--src/nvim/os/provider.c10
3 files changed, 20 insertions, 12 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index e14c427dc1..25454761ea 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -308,6 +308,16 @@ void vim_err_write(String str)
write_msg(str, true);
}
+/// Higher level error reporting function that ensures all str contents
+/// are written by sending a trailing linefeed to `vim_wrr_write`
+///
+/// @param str The message
+void vim_report_error(String str)
+{
+ vim_err_write(str);
+ vim_err_write((String) {.data = "\n", .size = 1});
+}
+
/// Gets the current list of buffer handles
///
/// @return The number of buffers
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 8becb29b26..d8c2e73150 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -12796,13 +12796,17 @@ static void f_send_call(typval_T *argvars, typval_T *rettv)
return;
}
+ if (errored) {
+ vim_report_error(result.data.string);
+ goto end;
+ }
+
Error conversion_error = {.set = false};
- if (errored || !object_to_vim(result, rettv, &conversion_error)) {
- EMSG(errored ?
- result.data.string.data :
- _("Error converting the call result"));
+ if (!object_to_vim(result, rettv, &conversion_error)) {
+ EMSG(_("Error converting the call result"));
}
+end:
api_free_object(result);
}
diff --git a/src/nvim/os/provider.c b/src/nvim/os/provider.c
index e56e33aa1a..9d8f6f297c 100644
--- a/src/nvim/os/provider.c
+++ b/src/nvim/os/provider.c
@@ -102,7 +102,7 @@ Object provider_call(char *method, Array args)
sizeof(buf),
"Provider for method \"%s\" is not available",
method);
- report_error(buf);
+ vim_report_error(cstr_as_string(buf));
api_free_array(args);
return NIL;
}
@@ -112,7 +112,7 @@ Object provider_call(char *method, Array args)
channel_send_call(f->channel_id, method, args, &result, &error);
if (error) {
- report_error(result.data.string.data);
+ vim_report_error(result.data.string);
api_free_object(result);
return NIL;
}
@@ -151,9 +151,3 @@ static Feature * find_feature(char *name)
return NULL;
}
-
-static void report_error(char *str)
-{
- vim_err_write((String) {.data = str, .size = strlen(str)});
- vim_err_write((String) {.data = "\n", .size = 1});
-}