mirror of
https://github.com/neovim/neovim.git
synced 2026-08-29 10:31:48 +00:00
feat(messages): cleanup Lua error messages
"Error" in error messages is redundant. Just provide the context, don't say "Error ...".
This commit is contained in:
@@ -110,9 +110,9 @@ Dict(cmd) nvim_parse_cmd(String str, Dict(empty) *opts, Arena *arena, Error *err
|
||||
|
||||
if (!parse_cmdline(cmdline, &ea, &cmdinfo, &errormsg)) {
|
||||
if (errormsg != NULL) {
|
||||
api_set_error(err, kErrorTypeException, "Error while parsing command line: %s", errormsg);
|
||||
api_set_error(err, kErrorTypeException, "Parsing command-line: %s", errormsg);
|
||||
} else {
|
||||
api_set_error(err, kErrorTypeException, "Error while parsing command line");
|
||||
api_set_error(err, kErrorTypeException, "Parsing command-line");
|
||||
}
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ static void decor_provider_error(DecorProvider *provider, const char *name, cons
|
||||
{
|
||||
const char *ns = describe_ns(provider->ns_id, "(UNKNOWN PLUGIN)");
|
||||
ELOG("Error in decoration provider \"%s\" (ns=%s):\n%s", name, ns, msg);
|
||||
msg_schedule_semsg_multiline("Error in decoration provider \"%s\" (ns=%s):\n%s", name, ns, msg);
|
||||
msg_schedule_semsg_multiline("Decoration provider \"%s\" (ns=%s):\n%s", name, ns, msg);
|
||||
}
|
||||
|
||||
// Note we pass in a provider index as this function may cause decor_providers providers to be
|
||||
|
||||
@@ -6357,10 +6357,10 @@ static void f_rpcrequest(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
name = get_client_info(chan, "name");
|
||||
}
|
||||
if (name) {
|
||||
semsg_multiline("rpc_error", "Error invoking '%s' on channel %" PRIu64 " (%s):\n%s",
|
||||
semsg_multiline("rpc_error", "Invoking '%s' on channel %" PRIu64 " (%s):\n%s",
|
||||
method, chan_id, name, err.msg);
|
||||
} else {
|
||||
semsg_multiline("rpc_error", "Error invoking '%s' on channel %" PRIu64 ":\n%s",
|
||||
semsg_multiline("rpc_error", "Invoking '%s' on channel %" PRIu64 ":\n%s",
|
||||
method, chan_id, err.msg);
|
||||
}
|
||||
|
||||
|
||||
@@ -192,13 +192,13 @@ static void nlua_luv_error_event(void **argv)
|
||||
luv_err_t type = (luv_err_t)(intptr_t)argv[1];
|
||||
switch (type) {
|
||||
case kCallback:
|
||||
semsg_multiline("lua_error", "Error executing callback:\n%s", error);
|
||||
semsg_multiline("lua_error", "Lua callback:\n%s", error);
|
||||
break;
|
||||
case kThread:
|
||||
semsg_multiline("lua_error", "Error in luv thread:\n%s", error);
|
||||
semsg_multiline("lua_error", "Luv thread:\n%s", error);
|
||||
break;
|
||||
case kThreadCallback:
|
||||
semsg_multiline("lua_error", "Error in luv callback, thread:\n%s", error);
|
||||
semsg_multiline("lua_error", "Luv callback, thread:\n%s", error);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -377,7 +377,7 @@ static void nlua_schedule_event(void **argv)
|
||||
nlua_pushref(lstate, cb);
|
||||
nlua_unref_global(lstate, cb);
|
||||
if (nlua_pcall(lstate, 0, 0)) {
|
||||
nlua_error(lstate, _("Error executing vim.schedule lua callback: %.*s"));
|
||||
nlua_error(lstate, _("vim.schedule callback: %.*s"));
|
||||
ui_remove_cb(ns_id, true);
|
||||
}
|
||||
}
|
||||
@@ -1032,7 +1032,7 @@ static int nlua_print(lua_State *const lstate)
|
||||
nlua_print_error:
|
||||
ga_clear(&msg_ga);
|
||||
char *buff = xmalloc(IOSIZE);
|
||||
const char *fmt = _("E5114: Error while converting print argument #%i: %.*s");
|
||||
const char *fmt = _("E5114: Converting print argument #%i: %.*s");
|
||||
size_t len = (size_t)vim_snprintf(buff, IOSIZE, fmt, curargidx,
|
||||
(int)errmsg_len, errmsg);
|
||||
lua_pushlstring(lstate, buff, len);
|
||||
@@ -1126,9 +1126,9 @@ static int nlua_debug(lua_State *lstate)
|
||||
}
|
||||
if (luaL_loadbuffer(lstate, input.vval.v_string,
|
||||
strlen(input.vval.v_string), "=(debug command)")) {
|
||||
nlua_error(lstate, _("E5115: Error while loading debug string: %.*s"));
|
||||
nlua_error(lstate, _("E5115: Loading Lua debug string: %.*s"));
|
||||
} else if (nlua_pcall(lstate, 0, 0)) {
|
||||
nlua_error(lstate, _("E5116: Error while calling debug string: %.*s"));
|
||||
nlua_error(lstate, _("E5116: Calling Lua debug string: %.*s"));
|
||||
}
|
||||
tv_clear(&input);
|
||||
}
|
||||
@@ -1436,7 +1436,7 @@ void nlua_call_user_expand_func(expand_T *xp, typval_T *ret_tv)
|
||||
lua_pushinteger(lstate, xp->xp_col);
|
||||
|
||||
if (nlua_pcall(lstate, 3, 1)) {
|
||||
nlua_error(lstate, _("E5108: Error executing Lua function: %.*s"));
|
||||
nlua_error(lstate, _("E5108: Lua function: %.*s"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1456,14 +1456,14 @@ static void nlua_typval_exec(const char *lcmd, size_t lcmd_len, const char *name
|
||||
|
||||
lua_State *const lstate = global_lstate;
|
||||
if (luaL_loadbuffer(lstate, lcmd, lcmd_len, name)) {
|
||||
nlua_error(lstate, _("E5107: Error loading lua %.*s"));
|
||||
nlua_error(lstate, _("E5107: Lua: %.*s"));
|
||||
return;
|
||||
}
|
||||
|
||||
PUSH_ALL_TYPVALS(lstate, args, argcount, special);
|
||||
|
||||
if (nlua_pcall(lstate, argcount, ret_tv ? 1 : 0)) {
|
||||
nlua_error(lstate, _("E5108: Error executing lua %.*s"));
|
||||
nlua_error(lstate, _("E5108: Lua: %.*s"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1525,8 +1525,7 @@ Object nlua_exec(const String str, const Array args, LuaRetMode mode, Arena *are
|
||||
if (luaL_loadbuffer(lstate, str.data, str.size, "<nvim>")) {
|
||||
size_t len;
|
||||
const char *errstr = lua_tolstring(lstate, -1, &len);
|
||||
api_set_error(err, kErrorTypeValidation,
|
||||
"Error loading lua: %.*s", (int)len, errstr);
|
||||
api_set_error(err, kErrorTypeValidation, "Lua: %.*s", (int)len, errstr);
|
||||
return NIL;
|
||||
}
|
||||
|
||||
@@ -1537,8 +1536,7 @@ Object nlua_exec(const String str, const Array args, LuaRetMode mode, Arena *are
|
||||
if (nlua_pcall(lstate, (int)args.size, 1)) {
|
||||
size_t len;
|
||||
const char *errstr = lua_tolstring(lstate, -1, &len);
|
||||
api_set_error(err, kErrorTypeException,
|
||||
"Error executing lua: %.*s", (int)len, errstr);
|
||||
api_set_error(err, kErrorTypeException, "Lua: %.*s", (int)len, errstr);
|
||||
return NIL;
|
||||
}
|
||||
|
||||
@@ -1598,10 +1596,9 @@ Object nlua_call_ref_ctx(bool fast, LuaRef ref, const char *name, Array args, Lu
|
||||
if (err) {
|
||||
size_t len;
|
||||
const char *errstr = lua_tolstring(lstate, -1, &len);
|
||||
api_set_error(err, kErrorTypeException,
|
||||
"Error executing lua: %.*s", (int)len, errstr);
|
||||
api_set_error(err, kErrorTypeException, "Lua: %.*s", (int)len, errstr);
|
||||
} else {
|
||||
nlua_error(lstate, _("Error executing lua callback: %.*s"));
|
||||
nlua_error(lstate, _("Lua callback: %.*s"));
|
||||
}
|
||||
return NIL;
|
||||
}
|
||||
@@ -1721,7 +1718,7 @@ void ex_luado(exarg_T *const eap)
|
||||
#undef DOEND
|
||||
|
||||
if (luaL_loadbuffer(lstate, lcmd, lcmd_len, ":luado")) {
|
||||
nlua_error(lstate, _("E5109: Error loading lua: %.*s"));
|
||||
nlua_error(lstate, _("E5109: Lua: %.*s"));
|
||||
if (lcmd_len >= IOSIZE) {
|
||||
xfree(lcmd);
|
||||
}
|
||||
@@ -1731,7 +1728,7 @@ void ex_luado(exarg_T *const eap)
|
||||
xfree(lcmd);
|
||||
}
|
||||
if (nlua_pcall(lstate, 0, 1)) {
|
||||
nlua_error(lstate, _("E5110: Error executing lua: %.*s"));
|
||||
nlua_error(lstate, _("E5110: Lua: %.*s"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1750,7 +1747,7 @@ void ex_luado(exarg_T *const eap)
|
||||
lua_pushstring(lstate, old_line);
|
||||
lua_pushnumber(lstate, (lua_Number)l);
|
||||
if (nlua_pcall(lstate, 2, 1)) {
|
||||
nlua_error(lstate, _("E5111: Error calling lua: %.*s"));
|
||||
nlua_error(lstate, _("E5111: Lua: %.*s"));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1845,7 +1842,7 @@ bool nlua_exec_file(const char *path)
|
||||
}
|
||||
|
||||
if (nlua_pcall(lstate, 1, 2)) {
|
||||
nlua_error(lstate, _("E5111: Error calling lua: %.*s"));
|
||||
nlua_error(lstate, _("E5111: Lua: %.*s"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1855,7 +1852,7 @@ bool nlua_exec_file(const char *path)
|
||||
|
||||
if (lua_isnil(lstate, -2)) {
|
||||
// 1
|
||||
nlua_error(lstate, _("E5112: Error while creating lua chunk: %.*s"));
|
||||
nlua_error(lstate, _("E5112: Lua chunk: %.*s"));
|
||||
assert(lua_isnil(lstate, -1));
|
||||
lua_pop(lstate, 1);
|
||||
return false;
|
||||
@@ -1866,7 +1863,7 @@ bool nlua_exec_file(const char *path)
|
||||
lua_pop(lstate, 1);
|
||||
|
||||
if (nlua_pcall(lstate, 0, 0)) {
|
||||
nlua_error(lstate, _("E5113: Error while calling lua chunk: %.*s"));
|
||||
nlua_error(lstate, _("E5113: Lua chunk: %.*s"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1945,7 +1942,7 @@ void nlua_expand_pat(expand_T *xp)
|
||||
lua_pushlstring(lstate, pat, (size_t)patlen);
|
||||
|
||||
if (nlua_pcall(lstate, 1, 2) != 0) {
|
||||
nlua_error(lstate, _("Error executing vim._expand_pat: %.*s"));
|
||||
nlua_error(lstate, _("vim._expand_pat: %.*s"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2093,7 +2090,7 @@ bool nlua_execute_on_key(int c, char *typed_buf)
|
||||
bool discard = false;
|
||||
// Do not use nlua_pcall here to avoid duplicate stack trace information
|
||||
if (lua_pcall(lstate, 2, 1, 0)) {
|
||||
nlua_error(lstate, _("Error executing vim.on_key() callbacks: %.*s"));
|
||||
nlua_error(lstate, _("vim.on_key() callbacks: %.*s"));
|
||||
} else {
|
||||
if (lua_isboolean(lstate, -1)) {
|
||||
discard = lua_toboolean(lstate, -1);
|
||||
@@ -2338,7 +2335,7 @@ int nlua_do_ucmd(ucmd_T *cmd, exarg_T *eap, bool preview)
|
||||
}
|
||||
|
||||
if (nlua_pcall(lstate, preview ? 3 : 1, preview ? 1 : 0)) {
|
||||
nlua_error(lstate, _("Error executing Lua callback: %.*s"));
|
||||
nlua_error(lstate, _("Lua :command callback: %.*s"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ char *nlua_read_secure(const char *path)
|
||||
lua_getfield(lstate, -1, "read");
|
||||
lua_pushstring(lstate, path);
|
||||
if (nlua_pcall(lstate, 1, 1)) {
|
||||
nlua_error(lstate, _("Error executing vim.secure.read: %.*s"));
|
||||
nlua_error(lstate, _("vim.secure.read: %.*s"));
|
||||
lua_settop(lstate, top);
|
||||
return NULL;
|
||||
}
|
||||
@@ -68,7 +68,7 @@ static bool nlua_trust(const char *action, const char *path)
|
||||
}
|
||||
|
||||
if (nlua_pcall(lstate, 1, 2)) {
|
||||
nlua_error(lstate, _("Error executing vim.secure.trust: %.*s"));
|
||||
nlua_error(lstate, _("vim.secure.trust: %.*s"));
|
||||
lua_settop(lstate, top);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ static const TSLanguage *load_language_from_wasm(lua_State *L, const char *path,
|
||||
}
|
||||
|
||||
if (werr.kind > 0) {
|
||||
luaL_error(L, "Error creating wasm store: (%s) %s", wasmerr_to_str(werr.kind), werr.message);
|
||||
luaL_error(L, "Failed to create WASM store: (%s) %s", wasmerr_to_str(werr.kind), werr.message);
|
||||
}
|
||||
|
||||
size_t file_size = 0;
|
||||
@@ -706,7 +706,7 @@ static void logger_cb(void *payload, TSLogType logtype, const char *s)
|
||||
lua_pushstring(lstate, logtype == TSLogTypeParse ? "parse" : "lex");
|
||||
lua_pushstring(lstate, s);
|
||||
if (lua_pcall(lstate, 2, 0, 0)) {
|
||||
luaL_error(lstate, "Error executing treesitter logger callback");
|
||||
luaL_error(lstate, "treesitter logger callback failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -341,8 +341,7 @@ int nlua_xdl_diff(lua_State *lstate)
|
||||
|
||||
if (xdl_diff(&ma, &mb, ¶ms, &cfg, &ecb) == -1) {
|
||||
if (!ERROR_SET(&err)) {
|
||||
api_set_error(&err, kErrorTypeException,
|
||||
"Error while performing diff operation");
|
||||
api_set_error(&err, kErrorTypeException, "diff operation failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2065,7 +2065,7 @@ static void do_exrc_initialization(void)
|
||||
nlua_exec(cstr_as_string(str), (Array)ARRAY_DICT_INIT, kRetNilBool, NULL, &err);
|
||||
xfree(str);
|
||||
if (ERROR_SET(&err)) {
|
||||
semsg("Error detected while processing %s:", VIMRC_LUA_FILE);
|
||||
semsg("Error in %s:", VIMRC_LUA_FILE);
|
||||
semsg_multiline("emsg", err.msg);
|
||||
api_clear_error(&err);
|
||||
}
|
||||
|
||||
@@ -593,7 +593,7 @@ static char *get_emsg_source(void)
|
||||
sname = SOURCING_NAME;
|
||||
}
|
||||
|
||||
const char *const p = _("Error detected while processing %s:");
|
||||
const char *const p = _("Error in %s:");
|
||||
const size_t buf_len = strlen(sname) + strlen(p) + 1;
|
||||
char *const buf = xmalloc(buf_len);
|
||||
snprintf(buf, buf_len, p, sname);
|
||||
|
||||
@@ -550,19 +550,16 @@ static ShaDaReadResult sd_reader_skip(FileDescriptor *const sd_reader, const siz
|
||||
{
|
||||
const ptrdiff_t skip_bytes = file_skip(sd_reader, offset);
|
||||
if (skip_bytes < 0) {
|
||||
semsg(_(SERR "System error while skipping in ShaDa file: %s"),
|
||||
os_strerror((int)skip_bytes));
|
||||
semsg(_(SERR "System error while skipping in ShaDa file: %s"), os_strerror((int)skip_bytes));
|
||||
return kSDReadStatusReadError;
|
||||
} else if (skip_bytes != (ptrdiff_t)offset) {
|
||||
assert(skip_bytes < (ptrdiff_t)offset);
|
||||
if (file_eof(sd_reader)) {
|
||||
semsg(_(RCERR "Error while reading ShaDa file: "
|
||||
"last entry specified that it occupies %" PRIu64 " bytes, "
|
||||
semsg(_(RCERR "Reading ShaDa file: last entry specified that it occupies %" PRIu64 " bytes, "
|
||||
"but file ended earlier"),
|
||||
(uint64_t)offset);
|
||||
} else {
|
||||
semsg(_(SERR "System error while skipping in ShaDa file: %s"),
|
||||
_("too few bytes read"));
|
||||
semsg(_(SERR "System error while skipping in ShaDa file: %s"), _("too few bytes read"));
|
||||
}
|
||||
return kSDReadStatusNotShaDa;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user