api: Do not translate error messages.

Also re-word some error messages:
- "Key does not exist: %s"
- "Invalid channel: %<PRIu64>"
- "Request array size must be 4 (request) or 3 (notification)"
- "String cannot contain newlines"

References #6150
This commit is contained in:
Justin M. Keyes 2017-04-23 22:30:08 +02:00
parent e2936ed397
commit 086c354a0a
13 changed files with 102 additions and 97 deletions

View File

@ -171,7 +171,7 @@ ArrayOf(String) nvim_buf_get_lines(uint64_t channel_id,
end = normalize_index(buf, end, &oob); end = normalize_index(buf, end, &oob);
if (strict_indexing && oob) { if (strict_indexing && oob) {
api_set_error(err, kErrorTypeValidation, _("Index out of bounds")); api_set_error(err, kErrorTypeValidation, "Index out of bounds");
return rv; return rv;
} }
@ -187,7 +187,7 @@ ArrayOf(String) nvim_buf_get_lines(uint64_t channel_id,
int64_t lnum = start + (int64_t)i; int64_t lnum = start + (int64_t)i;
if (lnum > LONG_MAX) { if (lnum > LONG_MAX) {
api_set_error(err, kErrorTypeValidation, _("Line index is too high")); api_set_error(err, kErrorTypeValidation, "Line index is too high");
goto end; goto end;
} }
@ -283,7 +283,7 @@ void nvim_buf_set_lines(uint64_t channel_id,
end = normalize_index(buf, end, &oob); end = normalize_index(buf, end, &oob);
if (strict_indexing && oob) { if (strict_indexing && oob) {
api_set_error(err, kErrorTypeValidation, _("Index out of bounds")); api_set_error(err, kErrorTypeValidation, "Index out of bounds");
return; return;
} }
@ -291,7 +291,7 @@ void nvim_buf_set_lines(uint64_t channel_id,
if (start > end) { if (start > end) {
api_set_error(err, api_set_error(err,
kErrorTypeValidation, kErrorTypeValidation,
_("Argument \"start\" is higher than \"end\"")); "Argument \"start\" is higher than \"end\"");
return; return;
} }
@ -306,7 +306,7 @@ void nvim_buf_set_lines(uint64_t channel_id,
if (replacement.items[i].type != kObjectTypeString) { if (replacement.items[i].type != kObjectTypeString) {
api_set_error(err, api_set_error(err,
kErrorTypeValidation, kErrorTypeValidation,
_("All items in the replacement array must be strings")); "All items in the replacement array must be strings");
goto end; goto end;
} }
@ -317,7 +317,8 @@ void nvim_buf_set_lines(uint64_t channel_id,
lines[i] = xmallocz(l.size); lines[i] = xmallocz(l.size);
for (size_t j = 0; j < l.size; j++) { for (size_t j = 0; j < l.size; j++) {
if (l.data[j] == '\n' && channel_id != INTERNAL_CALL) { if (l.data[j] == '\n' && channel_id != INTERNAL_CALL) {
api_set_error(err, kErrorTypeException, _("string cannot contain newlines")); api_set_error(err, kErrorTypeException,
"String cannot contain newlines");
new_len = i + 1; new_len = i + 1;
goto end; goto end;
} }
@ -330,7 +331,7 @@ void nvim_buf_set_lines(uint64_t channel_id,
switch_to_win_for_buf(buf, &save_curwin, &save_curtab, &save_curbuf); switch_to_win_for_buf(buf, &save_curwin, &save_curtab, &save_curbuf);
if (u_save((linenr_T)(start - 1), (linenr_T)end) == FAIL) { if (u_save((linenr_T)(start - 1), (linenr_T)end) == FAIL) {
api_set_error(err, kErrorTypeException, _("Failed to save undo information")); api_set_error(err, kErrorTypeException, "Failed to save undo information");
goto end; goto end;
} }
@ -340,7 +341,7 @@ void nvim_buf_set_lines(uint64_t channel_id,
size_t to_delete = (new_len < old_len) ? (size_t)(old_len - new_len) : 0; size_t to_delete = (new_len < old_len) ? (size_t)(old_len - new_len) : 0;
for (size_t i = 0; i < to_delete; i++) { for (size_t i = 0; i < to_delete; i++) {
if (ml_delete((linenr_T)start, false) == FAIL) { if (ml_delete((linenr_T)start, false) == FAIL) {
api_set_error(err, kErrorTypeException, _("Failed to delete line")); api_set_error(err, kErrorTypeException, "Failed to delete line");
goto end; goto end;
} }
} }
@ -357,12 +358,12 @@ void nvim_buf_set_lines(uint64_t channel_id,
int64_t lnum = start + (int64_t)i; int64_t lnum = start + (int64_t)i;
if (lnum > LONG_MAX) { if (lnum > LONG_MAX) {
api_set_error(err, kErrorTypeValidation, _("Index value is too high")); api_set_error(err, kErrorTypeValidation, "Index value is too high");
goto end; goto end;
} }
if (ml_replace((linenr_T)lnum, (char_u *)lines[i], false) == FAIL) { if (ml_replace((linenr_T)lnum, (char_u *)lines[i], false) == FAIL) {
api_set_error(err, kErrorTypeException, _("Failed to replace line")); api_set_error(err, kErrorTypeException, "Failed to replace line");
goto end; goto end;
} }
// Mark lines that haven't been passed to the buffer as they need // Mark lines that haven't been passed to the buffer as they need
@ -375,12 +376,12 @@ void nvim_buf_set_lines(uint64_t channel_id,
int64_t lnum = start + (int64_t)i - 1; int64_t lnum = start + (int64_t)i - 1;
if (lnum > LONG_MAX) { if (lnum > LONG_MAX) {
api_set_error(err, kErrorTypeValidation, _("Index value is too high")); api_set_error(err, kErrorTypeValidation, "Index value is too high");
goto end; goto end;
} }
if (ml_append((linenr_T)lnum, (char_u *)lines[i], 0, false) == FAIL) { if (ml_append((linenr_T)lnum, (char_u *)lines[i], 0, false) == FAIL) {
api_set_error(err, kErrorTypeException, _("Failed to insert line")); api_set_error(err, kErrorTypeException, "Failed to insert line");
goto end; goto end;
} }
@ -627,7 +628,7 @@ void nvim_buf_set_name(Buffer buffer, String name, Error *err)
} }
if (ren_ret == FAIL) { if (ren_ret == FAIL) {
api_set_error(err, kErrorTypeException, _("Failed to rename buffer")); api_set_error(err, kErrorTypeException, "Failed to rename buffer");
} }
} }
@ -680,7 +681,8 @@ ArrayOf(Integer, 2) nvim_buf_get_mark(Buffer buffer, String name, Error *err)
} }
if (name.size != 1) { if (name.size != 1) {
api_set_error(err, kErrorTypeValidation, _("Mark name must be a single character")); api_set_error(err, kErrorTypeValidation,
"Mark name must be a single character");
return rv; return rv;
} }
@ -698,7 +700,7 @@ ArrayOf(Integer, 2) nvim_buf_get_mark(Buffer buffer, String name, Error *err)
} }
if (posp == NULL) { if (posp == NULL) {
api_set_error(err, kErrorTypeValidation, _("Invalid mark name")); api_set_error(err, kErrorTypeValidation, "Invalid mark name");
return rv; return rv;
} }
@ -753,11 +755,11 @@ Integer nvim_buf_add_highlight(Buffer buffer,
} }
if (line < 0 || line >= MAXLNUM) { if (line < 0 || line >= MAXLNUM) {
api_set_error(err, kErrorTypeValidation, _("Line number outside range")); api_set_error(err, kErrorTypeValidation, "Line number outside range");
return 0; return 0;
} }
if (col_start < 0 || col_start > MAXCOL) { if (col_start < 0 || col_start > MAXCOL) {
api_set_error(err, kErrorTypeValidation, _("Column value outside range")); api_set_error(err, kErrorTypeValidation, "Column value outside range");
return 0; return 0;
} }
if (col_end < 0 || col_end > MAXCOL) { if (col_end < 0 || col_end > MAXCOL) {
@ -794,7 +796,7 @@ void nvim_buf_clear_highlight(Buffer buffer,
} }
if (line_start < 0 || line_start >= MAXLNUM) { if (line_start < 0 || line_start >= MAXLNUM) {
api_set_error(err, kErrorTypeValidation, _("Line number outside range")); api_set_error(err, kErrorTypeValidation, "Line number outside range");
return; return;
} }
if (line_end < 0 || line_end > MAXLNUM) { if (line_end < 0 || line_end > MAXLNUM) {

View File

@ -61,7 +61,7 @@ bool try_end(Error *err)
discard_current_exception(); discard_current_exception();
} }
api_set_error(err, kErrorTypeException, _("Keyboard interrupt")); api_set_error(err, kErrorTypeException, "Keyboard interrupt");
got_int = false; got_int = false;
} else if (msg_list != NULL && *msg_list != NULL) { } else if (msg_list != NULL && *msg_list != NULL) {
int should_free; int should_free;
@ -93,8 +93,8 @@ Object dict_get_value(dict_T *dict, String key, Error *err)
dictitem_T *const di = tv_dict_find(dict, key.data, (ptrdiff_t)key.size); dictitem_T *const di = tv_dict_find(dict, key.data, (ptrdiff_t)key.size);
if (di == NULL) { if (di == NULL) {
api_set_error(err, kErrorTypeValidation, _("Key not found")); api_set_error(err, kErrorTypeValidation, "Key not found");
return (Object) OBJECT_INIT; return (Object)OBJECT_INIT;
} }
return vim_to_object(&di->di_tv); return vim_to_object(&di->di_tv);
@ -117,17 +117,18 @@ Object dict_set_var(dict_T *dict, String key, Object value, bool del,
Object rv = OBJECT_INIT; Object rv = OBJECT_INIT;
if (dict->dv_lock) { if (dict->dv_lock) {
api_set_error(err, kErrorTypeException, _("Dictionary is locked")); api_set_error(err, kErrorTypeException, "Dictionary is locked");
return rv; return rv;
} }
if (key.size == 0) { if (key.size == 0) {
api_set_error(err, kErrorTypeValidation, _("Empty variable names aren't allowed")); api_set_error(err, kErrorTypeValidation,
"Empty variable names aren't allowed");
return rv; return rv;
} }
if (key.size > INT_MAX) { if (key.size > INT_MAX) {
api_set_error(err, kErrorTypeValidation, _("Key length is too high")); api_set_error(err, kErrorTypeValidation, "Key length is too high");
return rv; return rv;
} }
@ -135,13 +136,13 @@ Object dict_set_var(dict_T *dict, String key, Object value, bool del,
if (di != NULL) { if (di != NULL) {
if (di->di_flags & DI_FLAGS_RO) { if (di->di_flags & DI_FLAGS_RO) {
api_set_error(err, kErrorTypeException, _("Key is read-only: %s"), key.data); api_set_error(err, kErrorTypeException, "Key is read-only: %s", key.data);
return rv; return rv;
} else if (di->di_flags & DI_FLAGS_FIX) { } else if (di->di_flags & DI_FLAGS_FIX) {
api_set_error(err, kErrorTypeException, _("Key is fixed: %s"), key.data); api_set_error(err, kErrorTypeException, "Key is fixed: %s", key.data);
return rv; return rv;
} else if (di->di_flags & DI_FLAGS_LOCK) { } else if (di->di_flags & DI_FLAGS_LOCK) {
api_set_error(err, kErrorTypeException, _("Key is locked: %s"), key.data); api_set_error(err, kErrorTypeException, "Key is locked: %s", key.data);
return rv; return rv;
} }
} }
@ -150,7 +151,8 @@ Object dict_set_var(dict_T *dict, String key, Object value, bool del,
// Delete the key // Delete the key
if (di == NULL) { if (di == NULL) {
// Doesn't exist, fail // Doesn't exist, fail
api_set_error(err, kErrorTypeValidation, _("Key \"%s\" doesn't exist"), key.data); api_set_error(err, kErrorTypeValidation, "Key does not exist: %s",
key.data);
} else { } else {
// Return the old value // Return the old value
if (retval) { if (retval) {
@ -202,7 +204,7 @@ Object get_option_from(void *from, int type, String name, Error *err)
Object rv = OBJECT_INIT; Object rv = OBJECT_INIT;
if (name.size == 0) { if (name.size == 0) {
api_set_error(err, kErrorTypeValidation, _("Empty option name")); api_set_error(err, kErrorTypeValidation, "Empty option name");
return rv; return rv;
} }
@ -215,7 +217,7 @@ Object get_option_from(void *from, int type, String name, Error *err)
if (!flags) { if (!flags) {
api_set_error(err, api_set_error(err,
kErrorTypeValidation, kErrorTypeValidation,
_("Invalid option name \"%s\""), "Invalid option name \"%s\"",
name.data); name.data);
return rv; return rv;
} }
@ -234,13 +236,13 @@ Object get_option_from(void *from, int type, String name, Error *err)
} else { } else {
api_set_error(err, api_set_error(err,
kErrorTypeException, kErrorTypeException,
_("Unable to get value for option \"%s\""), "Unable to get value for option \"%s\"",
name.data); name.data);
} }
} else { } else {
api_set_error(err, api_set_error(err,
kErrorTypeException, kErrorTypeException,
_("Unknown type for option \"%s\""), "Unknown type for option \"%s\"",
name.data); name.data);
} }
@ -257,7 +259,7 @@ Object get_option_from(void *from, int type, String name, Error *err)
void set_option_to(void *to, int type, String name, Object value, Error *err) void set_option_to(void *to, int type, String name, Object value, Error *err)
{ {
if (name.size == 0) { if (name.size == 0) {
api_set_error(err, kErrorTypeValidation, _("Empty option name")); api_set_error(err, kErrorTypeValidation, "Empty option name");
return; return;
} }
@ -266,7 +268,7 @@ void set_option_to(void *to, int type, String name, Object value, Error *err)
if (flags == 0) { if (flags == 0) {
api_set_error(err, api_set_error(err,
kErrorTypeValidation, kErrorTypeValidation,
_("Invalid option name \"%s\""), "Invalid option name \"%s\"",
name.data); name.data);
return; return;
} }
@ -275,14 +277,14 @@ void set_option_to(void *to, int type, String name, Object value, Error *err)
if (type == SREQ_GLOBAL) { if (type == SREQ_GLOBAL) {
api_set_error(err, api_set_error(err,
kErrorTypeException, kErrorTypeException,
_("Unable to unset option \"%s\""), "Unable to unset option \"%s\"",
name.data); name.data);
return; return;
} else if (!(flags & SOPT_GLOBAL)) { } else if (!(flags & SOPT_GLOBAL)) {
api_set_error(err, api_set_error(err,
kErrorTypeException, kErrorTypeException,
_("Cannot unset option \"%s\" " "Cannot unset option \"%s\" "
"because it doesn't have a global value"), "because it doesn't have a global value",
name.data); name.data);
return; return;
} else { } else {
@ -297,7 +299,7 @@ void set_option_to(void *to, int type, String name, Object value, Error *err)
if (value.type != kObjectTypeBoolean) { if (value.type != kObjectTypeBoolean) {
api_set_error(err, api_set_error(err,
kErrorTypeValidation, kErrorTypeValidation,
_("Option \"%s\" requires a boolean value"), "Option \"%s\" requires a boolean value",
name.data); name.data);
return; return;
} }
@ -308,7 +310,7 @@ void set_option_to(void *to, int type, String name, Object value, Error *err)
if (value.type != kObjectTypeInteger) { if (value.type != kObjectTypeInteger) {
api_set_error(err, api_set_error(err,
kErrorTypeValidation, kErrorTypeValidation,
_("Option \"%s\" requires an integer value"), "Option \"%s\" requires an integer value",
name.data); name.data);
return; return;
} }
@ -316,7 +318,7 @@ void set_option_to(void *to, int type, String name, Object value, Error *err)
if (value.data.integer > INT_MAX || value.data.integer < INT_MIN) { if (value.data.integer > INT_MAX || value.data.integer < INT_MIN) {
api_set_error(err, api_set_error(err,
kErrorTypeValidation, kErrorTypeValidation,
_("Value for option \"%s\" is outside range"), "Value for option \"%s\" is outside range",
name.data); name.data);
return; return;
} }
@ -327,7 +329,7 @@ void set_option_to(void *to, int type, String name, Object value, Error *err)
if (value.type != kObjectTypeString) { if (value.type != kObjectTypeString) {
api_set_error(err, api_set_error(err,
kErrorTypeValidation, kErrorTypeValidation,
_("Option \"%s\" requires a string value"), "Option \"%s\" requires a string value",
name.data); name.data);
return; return;
} }
@ -560,7 +562,7 @@ buf_T *find_buffer_by_handle(Buffer buffer, Error *err)
buf_T *rv = handle_get_buffer(buffer); buf_T *rv = handle_get_buffer(buffer);
if (!rv) { if (!rv) {
api_set_error(err, kErrorTypeValidation, _("Invalid buffer id")); api_set_error(err, kErrorTypeValidation, "Invalid buffer id");
} }
return rv; return rv;
@ -575,7 +577,7 @@ win_T *find_window_by_handle(Window window, Error *err)
win_T *rv = handle_get_window(window); win_T *rv = handle_get_window(window);
if (!rv) { if (!rv) {
api_set_error(err, kErrorTypeValidation, _("Invalid window id")); api_set_error(err, kErrorTypeValidation, "Invalid window id");
} }
return rv; return rv;
@ -590,7 +592,7 @@ tabpage_T *find_tab_by_handle(Tabpage tabpage, Error *err)
tabpage_T *rv = handle_get_tabpage(tabpage); tabpage_T *rv = handle_get_tabpage(tabpage);
if (!rv) { if (!rv) {
api_set_error(err, kErrorTypeValidation, _("Invalid tabpage id")); api_set_error(err, kErrorTypeValidation, "Invalid tabpage id");
} }
return rv; return rv;
@ -658,7 +660,7 @@ bool object_to_vim(Object obj, typval_T *tv, Error *err)
case kObjectTypeInteger: case kObjectTypeInteger:
if (obj.data.integer > VARNUMBER_MAX if (obj.data.integer > VARNUMBER_MAX
|| obj.data.integer < VARNUMBER_MIN) { || obj.data.integer < VARNUMBER_MIN) {
api_set_error(err, kErrorTypeValidation, _("Integer value outside range")); api_set_error(err, kErrorTypeValidation, "Integer value outside range");
return false; return false;
} }
@ -713,7 +715,7 @@ bool object_to_vim(Object obj, typval_T *tv, Error *err)
if (key.size == 0) { if (key.size == 0) {
api_set_error(err, kErrorTypeValidation, api_set_error(err, kErrorTypeValidation,
_("Empty dictionary keys aren't allowed")); "Empty dictionary keys aren't allowed");
// cleanup // cleanup
tv_dict_free(dict); tv_dict_free(dict);
return false; return false;
@ -938,7 +940,7 @@ static void set_option_value_for(char *key,
} }
api_set_error(err, api_set_error(err,
kErrorTypeException, kErrorTypeException,
_("Problem while switching windows")); "Problem while switching windows");
return; return;
} }
set_option_value_err(key, numval, stringval, opt_flags, err); set_option_value_err(key, numval, stringval, opt_flags, err);

View File

@ -55,13 +55,13 @@ void nvim_ui_attach(uint64_t channel_id, Integer width, Integer height,
FUNC_API_SINCE(1) FUNC_API_NOEVAL FUNC_API_SINCE(1) FUNC_API_NOEVAL
{ {
if (pmap_has(uint64_t)(connected_uis, channel_id)) { if (pmap_has(uint64_t)(connected_uis, channel_id)) {
api_set_error(err, kErrorTypeException, _("UI already attached for channel")); api_set_error(err, kErrorTypeException, "UI already attached for channel");
return; return;
} }
if (width <= 0 || height <= 0) { if (width <= 0 || height <= 0) {
api_set_error(err, kErrorTypeValidation, api_set_error(err, kErrorTypeValidation,
_("Expected width > 0 and height > 0")); "Expected width > 0 and height > 0");
return; return;
} }
UI *ui = xcalloc(1, sizeof(UI)); UI *ui = xcalloc(1, sizeof(UI));
@ -126,7 +126,7 @@ void nvim_ui_detach(uint64_t channel_id, Error *err)
FUNC_API_SINCE(1) FUNC_API_NOEVAL FUNC_API_SINCE(1) FUNC_API_NOEVAL
{ {
if (!pmap_has(uint64_t)(connected_uis, channel_id)) { if (!pmap_has(uint64_t)(connected_uis, channel_id)) {
api_set_error(err, kErrorTypeException, _("UI is not attached for channel")); api_set_error(err, kErrorTypeException, "UI is not attached for channel");
return; return;
} }
remote_ui_disconnect(channel_id); remote_ui_disconnect(channel_id);
@ -138,13 +138,13 @@ void nvim_ui_try_resize(uint64_t channel_id, Integer width,
FUNC_API_SINCE(1) FUNC_API_NOEVAL FUNC_API_SINCE(1) FUNC_API_NOEVAL
{ {
if (!pmap_has(uint64_t)(connected_uis, channel_id)) { if (!pmap_has(uint64_t)(connected_uis, channel_id)) {
api_set_error(err, kErrorTypeException, _("UI is not attached for channel")); api_set_error(err, kErrorTypeException, "UI is not attached for channel");
return; return;
} }
if (width <= 0 || height <= 0) { if (width <= 0 || height <= 0) {
api_set_error(err, kErrorTypeValidation, api_set_error(err, kErrorTypeValidation,
_("Expected width > 0 and height > 0")); "Expected width > 0 and height > 0");
return; return;
} }
@ -159,7 +159,7 @@ void nvim_ui_set_option(uint64_t channel_id, String name,
FUNC_API_SINCE(1) FUNC_API_NOEVAL FUNC_API_SINCE(1) FUNC_API_NOEVAL
{ {
if (!pmap_has(uint64_t)(connected_uis, channel_id)) { if (!pmap_has(uint64_t)(connected_uis, channel_id)) {
api_set_error(error, kErrorTypeException, _("UI is not attached for channel")); api_set_error(error, kErrorTypeException, "UI is not attached for channel");
return; return;
} }
UI *ui = pmap_get(uint64_t)(connected_uis, channel_id); UI *ui = pmap_get(uint64_t)(connected_uis, channel_id);
@ -173,19 +173,19 @@ void nvim_ui_set_option(uint64_t channel_id, String name,
static void ui_set_option(UI *ui, String name, Object value, Error *error) { static void ui_set_option(UI *ui, String name, Object value, Error *error) {
if (strcmp(name.data, "rgb") == 0) { if (strcmp(name.data, "rgb") == 0) {
if (value.type != kObjectTypeBoolean) { if (value.type != kObjectTypeBoolean) {
api_set_error(error, kErrorTypeValidation, _("rgb must be a Boolean")); api_set_error(error, kErrorTypeValidation, "rgb must be a Boolean");
return; return;
} }
ui->rgb = value.data.boolean; ui->rgb = value.data.boolean;
} else if (strcmp(name.data, "popupmenu_external") == 0) { } else if (strcmp(name.data, "popupmenu_external") == 0) {
if (value.type != kObjectTypeBoolean) { if (value.type != kObjectTypeBoolean) {
api_set_error(error, kErrorTypeValidation, api_set_error(error, kErrorTypeValidation,
_("popupmenu_external must be a Boolean")); "popupmenu_external must be a Boolean");
return; return;
} }
ui->pum_external = value.data.boolean; ui->pum_external = value.data.boolean;
} else { } else {
api_set_error(error, kErrorTypeValidation, _("No such ui option")); api_set_error(error, kErrorTypeValidation, "No such ui option");
} }
} }

View File

@ -166,7 +166,7 @@ String nvim_command_output(String str, Error *err)
do_cmdline_cmd("redir END"); do_cmdline_cmd("redir END");
if (ERROR_SET(err)) { if (ERROR_SET(err)) {
return (String) STRING_INIT; return (String)STRING_INIT;
} }
return cstr_to_string((char *)get_vim_var_str(VV_COMMAND_OUTPUT)); return cstr_to_string((char *)get_vim_var_str(VV_COMMAND_OUTPUT));
@ -215,7 +215,7 @@ Object nvim_call_function(String fname, Array args, Error *err)
Object rv = OBJECT_INIT; Object rv = OBJECT_INIT;
if (args.size > MAX_FUNC_ARGS) { if (args.size > MAX_FUNC_ARGS) {
api_set_error(err, kErrorTypeValidation, api_set_error(err, kErrorTypeValidation,
_("Function called with too many arguments.")); "Function called with too many arguments.");
return rv; 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, curwin->w_cursor.lnum, curwin->w_cursor.lnum, &dummy,
true, NULL, NULL); true, NULL, NULL);
if (r == FAIL) { if (r == FAIL) {
api_set_error(err, kErrorTypeException, _("Error calling function.")); api_set_error(err, kErrorTypeException, "Error calling function.");
} }
if (!try_end(err)) { if (!try_end(err)) {
rv = vim_to_object(&rettv); rv = vim_to_object(&rettv);
@ -262,7 +262,7 @@ Integer nvim_strwidth(String str, Error *err)
FUNC_API_SINCE(1) FUNC_API_SINCE(1)
{ {
if (str.size > INT_MAX) { if (str.size > INT_MAX) {
api_set_error(err, kErrorTypeValidation, _("String length is too high")); api_set_error(err, kErrorTypeValidation, "String length is too high");
return 0; return 0;
} }
@ -318,7 +318,7 @@ void nvim_set_current_dir(String dir, Error *err)
FUNC_API_SINCE(1) FUNC_API_SINCE(1)
{ {
if (dir.size >= MAXPATHL) { if (dir.size >= MAXPATHL) {
api_set_error(err, kErrorTypeValidation, _("Directory string is too long")); api_set_error(err, kErrorTypeValidation, "Directory string is too long");
return; return;
} }
@ -330,7 +330,7 @@ void nvim_set_current_dir(String dir, Error *err)
if (vim_chdir((char_u *)string, kCdScopeGlobal)) { if (vim_chdir((char_u *)string, kCdScopeGlobal)) {
if (!try_end(err)) { if (!try_end(err)) {
api_set_error(err, kErrorTypeException, _("Failed to change directory")); api_set_error(err, kErrorTypeException, "Failed to change directory");
} }
return; return;
} }
@ -540,7 +540,7 @@ void nvim_set_current_buf(Buffer buffer, Error *err)
if (!try_end(err) && result == FAIL) { if (!try_end(err) && result == FAIL) {
api_set_error(err, api_set_error(err,
kErrorTypeException, kErrorTypeException,
_("Failed to switch to buffer %d"), "Failed to switch to buffer %d",
buffer); buffer);
} }
} }
@ -593,7 +593,7 @@ void nvim_set_current_win(Window window, Error *err)
if (!try_end(err) && win != curwin) { if (!try_end(err) && win != curwin) {
api_set_error(err, api_set_error(err,
kErrorTypeException, kErrorTypeException,
_("Failed to switch to window %d"), "Failed to switch to window %d",
window); window);
} }
} }
@ -647,7 +647,7 @@ void nvim_set_current_tabpage(Tabpage tabpage, Error *err)
if (!try_end(err) && tp != curtab) { if (!try_end(err) && tp != curtab) {
api_set_error(err, api_set_error(err,
kErrorTypeException, kErrorTypeException,
_("Failed to switch to tabpage %d"), "Failed to switch to tabpage %d",
tabpage); tabpage);
} }
} }
@ -746,21 +746,21 @@ Array nvim_call_atomic(uint64_t channel_id, Array calls, Error *err)
if (calls.items[i].type != kObjectTypeArray) { if (calls.items[i].type != kObjectTypeArray) {
api_set_error(err, api_set_error(err,
kErrorTypeValidation, kErrorTypeValidation,
_("All items in calls array must be arrays")); "All items in calls array must be arrays");
goto validation_error; goto validation_error;
} }
Array call = calls.items[i].data.array; Array call = calls.items[i].data.array;
if (call.size != 2) { if (call.size != 2) {
api_set_error(err, api_set_error(err,
kErrorTypeValidation, kErrorTypeValidation,
_("All items in calls array must be arrays of size 2")); "All items in calls array must be arrays of size 2");
goto validation_error; goto validation_error;
} }
if (call.items[0].type != kObjectTypeString) { if (call.items[0].type != kObjectTypeString) {
api_set_error(err, api_set_error(err,
kErrorTypeValidation, kErrorTypeValidation,
_("name must be String")); "Name must be String");
goto validation_error; goto validation_error;
} }
String name = call.items[0].data.string; String name = call.items[0].data.string;
@ -768,7 +768,7 @@ Array nvim_call_atomic(uint64_t channel_id, Array calls, Error *err)
if (call.items[1].type != kObjectTypeArray) { if (call.items[1].type != kObjectTypeArray) {
api_set_error(err, api_set_error(err,
kErrorTypeValidation, kErrorTypeValidation,
_("args must be Array")); "Args must be Array");
goto validation_error; goto validation_error;
} }
Array args = call.items[1].data.array; Array args = call.items[1].data.array;

View File

@ -66,7 +66,7 @@ void nvim_win_set_cursor(Window window, ArrayOf(Integer, 2) pos, Error *err)
|| pos.items[1].type != kObjectTypeInteger) { || pos.items[1].type != kObjectTypeInteger) {
api_set_error(err, api_set_error(err,
kErrorTypeValidation, kErrorTypeValidation,
_("Argument \"pos\" must be a [row, col] array")); "Argument \"pos\" must be a [row, col] array");
return; return;
} }
@ -78,12 +78,12 @@ void nvim_win_set_cursor(Window window, ArrayOf(Integer, 2) pos, Error *err)
int64_t col = pos.items[1].data.integer; int64_t col = pos.items[1].data.integer;
if (row <= 0 || row > win->w_buffer->b_ml.ml_line_count) { if (row <= 0 || row > win->w_buffer->b_ml.ml_line_count) {
api_set_error(err, kErrorTypeValidation, _("Cursor position outside buffer")); api_set_error(err, kErrorTypeValidation, "Cursor position outside buffer");
return; return;
} }
if (col > MAXCOL || col < 0) { if (col > MAXCOL || col < 0) {
api_set_error(err, kErrorTypeValidation, _("Column value outside range")); api_set_error(err, kErrorTypeValidation, "Column value outside range");
return; return;
} }
@ -132,7 +132,7 @@ void nvim_win_set_height(Window window, Integer height, Error *err)
} }
if (height > INT_MAX || height < INT_MIN) { if (height > INT_MAX || height < INT_MIN) {
api_set_error(err, kErrorTypeValidation, _("Height value outside range")); api_set_error(err, kErrorTypeValidation, "Height value outside range");
return; return;
} }
@ -177,7 +177,7 @@ void nvim_win_set_width(Window window, Integer width, Error *err)
} }
if (width > INT_MAX || width < INT_MIN) { if (width > INT_MAX || width < INT_MIN) {
api_set_error(err, kErrorTypeValidation, _("Width value outside range")); api_set_error(err, kErrorTypeValidation, "Width value outside range");
return; return;
} }

View File

@ -192,7 +192,7 @@ Object channel_send_call(uint64_t id,
Channel *channel = NULL; Channel *channel = NULL;
if (!(channel = pmap_get(uint64_t)(channels, id)) || channel->closed) { 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); api_free_array(args);
return NIL; return NIL;
} }
@ -212,7 +212,8 @@ Object channel_send_call(uint64_t id,
if (frame.errored) { if (frame.errored) {
if (frame.result.type == kObjectTypeString) { 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) { } else if (frame.result.type == kObjectTypeArray) {
// Should be an error in the form [type, message] // Should be an error in the form [type, message]
Array array = frame.result.data.array; Array array = frame.result.data.array;
@ -221,7 +222,7 @@ Object channel_send_call(uint64_t id,
|| array.items[0].data.integer == kErrorTypeValidation) || array.items[0].data.integer == kErrorTypeValidation)
&& array.items[1].type == kObjectTypeString) { && 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); array.items[1].data.string.data);
} else { } else {
api_set_error(err, kErrorTypeException, "%s", "unknown error"); api_set_error(err, kErrorTypeException, "%s", "unknown error");
} }

View File

@ -570,49 +570,49 @@ void msgpack_rpc_validate(uint64_t *response_id,
*response_id = NO_RESPONSE; *response_id = NO_RESPONSE;
// Validate the basic structure of the msgpack-rpc payload // Validate the basic structure of the msgpack-rpc payload
if (req->type != MSGPACK_OBJECT_ARRAY) { 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; return;
} }
if (req->via.array.size == 0) { if (req->via.array.size == 0) {
api_set_error(err, kErrorTypeValidation, _("Message is empty")); api_set_error(err, kErrorTypeValidation, "Message is empty");
return; return;
} }
if (req->via.array.ptr[0].type != MSGPACK_OBJECT_POSITIVE_INTEGER) { 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; return;
} }
uint64_t type = req->via.array.ptr[0].via.u64; uint64_t type = req->via.array.ptr[0].via.u64;
if (type != kMessageTypeRequest && type != kMessageTypeNotification) { if (type != kMessageTypeRequest && type != kMessageTypeNotification) {
api_set_error(err, kErrorTypeValidation, _("Unknown message type")); api_set_error(err, kErrorTypeValidation, "Unknown message type");
return; return;
} }
if ((type == kMessageTypeRequest && req->via.array.size != 4) if ((type == kMessageTypeRequest && req->via.array.size != 4)
|| (type == kMessageTypeNotification && req->via.array.size != 3)) { || (type == kMessageTypeNotification && req->via.array.size != 3)) {
api_set_error(err, kErrorTypeValidation, _("Request array size should be 4 (request) " api_set_error(err, kErrorTypeValidation,
"or 3 (notification)")); "Request array size must be 4 (request) or 3 (notification)");
return; return;
} }
if (type == kMessageTypeRequest) { if (type == kMessageTypeRequest) {
msgpack_object *id_obj = msgpack_rpc_msg_id(req); msgpack_object *id_obj = msgpack_rpc_msg_id(req);
if (!id_obj) { 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; return;
} }
*response_id = id_obj->via.u64; *response_id = id_obj->via.u64;
} }
if (!msgpack_rpc_method(req)) { 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; return;
} }
if (!msgpack_rpc_args(req)) { 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; return;
} }
} }

View File

@ -116,7 +116,7 @@ msgstr "merkkijono ei saa sisältää rivinvaihtoja"
#. Doesn't exist, fail #. Doesn't exist, fail
#, fuzzy, c-format #, fuzzy, c-format
#~ msgid "Key \"%s\" doesn't exist" #~ msgid "Key does not exist: %s"
#~ msgstr "Tiedostoa %s ei ole" #~ msgstr "Tiedostoa %s ei ole"
#, fuzzy #, fuzzy
@ -3986,7 +3986,7 @@ msgid "Calling shell to execute: \"%s\""
msgstr "Kutsutaan kuorta suorittamaan: %s" msgstr "Kutsutaan kuorta suorittamaan: %s"
#, c-format #, c-format
#~ msgid "Invalid channel \"%<PRIu64>\"" #~ msgid "Invalid channel: %<PRIu64>"
#~ msgstr "" #~ msgstr ""
#~ msgid "Message is not an array" #~ msgid "Message is not an array"
@ -4003,7 +4003,7 @@ msgstr "Kutsutaan kuorta suorittamaan: %s"
#~ msgid "Unknown message type" #~ msgid "Unknown message type"
#~ msgstr "E574: Tuntematon rekisterityyppi %d" #~ msgstr "E574: Tuntematon rekisterityyppi %d"
#~ msgid "Request array size should be 4 (request) or 3 (notification)" #~ msgid "Request array size must be 4 (request) or 3 (notification)"
#~ msgstr "" #~ msgstr ""
#~ msgid "ID must be a positive integer" #~ msgid "ID must be a positive integer"

View File

@ -82,7 +82,7 @@ msgid "Key length is too high"
msgstr "Довжина ключа завелика" msgstr "Довжина ключа завелика"
#, c-format #, c-format
msgid "Key \"%s\" doesn't exist" msgid "Key does not exist: %s"
msgstr "Ключ «%s» не існує" msgstr "Ключ «%s» не існує"
msgid "Empty option name" msgid "Empty option name"
@ -3719,7 +3719,7 @@ msgid "Calling shell to execute: \"%s\""
msgstr "Викликається оболонка щоб виконати: «%s»" msgstr "Викликається оболонка щоб виконати: «%s»"
#, c-format #, c-format
msgid "Invalid channel \"%<PRIu64>\"" msgid "Invalid channel: %<PRIu64>"
msgstr "Некоректний канал «%<PRIu64>»" msgstr "Некоректний канал «%<PRIu64>»"
msgid "Message is not an array" msgid "Message is not an array"
@ -3734,7 +3734,7 @@ msgstr "Повідомлення має бути цілим числом"
msgid "Unknown message type" msgid "Unknown message type"
msgstr "Невідомий тип повідомлення" msgstr "Невідомий тип повідомлення"
msgid "Request array size should be 4 (request) or 3 (notification)" msgid "Request array size must be 4 (request) or 3 (notification)"
msgstr "Розмір масиву запиту має бути 4 (запит) чи 3 (повідомлення)" msgstr "Розмір масиву запиту має бути 4 (запит) чи 3 (повідомлення)"
msgid "ID must be a positive integer" msgid "ID must be a positive integer"

View File

@ -271,7 +271,7 @@ describe('api/buf', function()
eq(1, funcs.exists('b:lua')) eq(1, funcs.exists('b:lua'))
curbufmeths.del_var('lua') curbufmeths.del_var('lua')
eq(0, funcs.exists('b:lua')) eq(0, funcs.exists('b:lua'))
eq({false, 'Key "lua" doesn\'t exist'}, meth_pcall(curbufmeths.del_var, 'lua')) eq({false, 'Key does not exist: lua'}, meth_pcall(curbufmeths.del_var, 'lua'))
curbufmeths.set_var('lua', 1) curbufmeths.set_var('lua', 1)
command('lockvar b:lua') command('lockvar b:lua')
eq({false, 'Key is locked: lua'}, meth_pcall(curbufmeths.del_var, 'lua')) eq({false, 'Key is locked: lua'}, meth_pcall(curbufmeths.del_var, 'lua'))

View File

@ -34,7 +34,7 @@ describe('api/tabpage', function()
eq(1, funcs.exists('t:lua')) eq(1, funcs.exists('t:lua'))
curtabmeths.del_var('lua') curtabmeths.del_var('lua')
eq(0, funcs.exists('t:lua')) eq(0, funcs.exists('t:lua'))
eq({false, 'Key "lua" doesn\'t exist'}, meth_pcall(curtabmeths.del_var, 'lua')) eq({false, 'Key does not exist: lua'}, meth_pcall(curtabmeths.del_var, 'lua'))
curtabmeths.set_var('lua', 1) curtabmeths.set_var('lua', 1)
command('lockvar t:lua') command('lockvar t:lua')
eq({false, 'Key is locked: lua'}, meth_pcall(curtabmeths.del_var, 'lua')) eq({false, 'Key is locked: lua'}, meth_pcall(curtabmeths.del_var, 'lua'))

View File

@ -119,7 +119,7 @@ describe('api', function()
eq(1, funcs.exists('g:lua')) eq(1, funcs.exists('g:lua'))
meths.del_var('lua') meths.del_var('lua')
eq(0, funcs.exists('g:lua')) eq(0, funcs.exists('g:lua'))
eq({false, 'Key "lua" doesn\'t exist'}, meth_pcall(meths.del_var, 'lua')) eq({false, 'Key does not exist: lua'}, meth_pcall(meths.del_var, 'lua'))
meths.set_var('lua', 1) meths.set_var('lua', 1)
command('lockvar lua') command('lockvar lua')
eq({false, 'Key is locked: lua'}, meth_pcall(meths.del_var, 'lua')) eq({false, 'Key is locked: lua'}, meth_pcall(meths.del_var, 'lua'))
@ -439,7 +439,7 @@ describe('api', function()
} }
status, err = pcall(meths.call_atomic, req) status, err = pcall(meths.call_atomic, req)
eq(false, status) eq(false, status)
ok(err:match('args must be Array') ~= nil) ok(err:match('Args must be Array') ~= nil)
-- call before was done, but not after -- call before was done, but not after
eq(1, meths.get_var('avar')) eq(1, meths.get_var('avar'))
eq({''}, meths.buf_get_lines(0, 0, -1, true)) eq({''}, meths.buf_get_lines(0, 0, -1, true))

View File

@ -139,7 +139,7 @@ describe('api/win', function()
eq(1, funcs.exists('w:lua')) eq(1, funcs.exists('w:lua'))
curwinmeths.del_var('lua') curwinmeths.del_var('lua')
eq(0, funcs.exists('w:lua')) eq(0, funcs.exists('w:lua'))
eq({false, 'Key "lua" doesn\'t exist'}, meth_pcall(curwinmeths.del_var, 'lua')) eq({false, 'Key does not exist: lua'}, meth_pcall(curwinmeths.del_var, 'lua'))
curwinmeths.set_var('lua', 1) curwinmeths.set_var('lua', 1)
command('lockvar w:lua') command('lockvar w:lua')
eq({false, 'Key is locked: lua'}, meth_pcall(curwinmeths.del_var, 'lua')) eq({false, 'Key is locked: lua'}, meth_pcall(curwinmeths.del_var, 'lua'))