From fc2dee17368d76e7e845872990bb6fdef1c6bf54 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 23 Aug 2021 02:37:07 -0700 Subject: feat(messages): cleanup Lua error messages "Error" in error messages is redundant. Just provide the context, don't say "Error ...". --- src/nvim/lua/executor.c | 49 +++++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 26 deletions(-) (limited to 'src/nvim/lua/executor.c') diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index 6eb723ff76..617921efd6 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -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, "")) { 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; } -- cgit