Expose Lua error in case of string error. (#10677)

In general, our error handler make sure the error
object is always a table. In some rare cases (such
as OOM error), the error handler will not be called
and the error object will be a string. The PR expose
the error even if its a string and not a table.

Currently there is no way to test it but if it'll ever happen,
it is better to propagate this string upwards than just
generate a generic error without any specific info.
This commit is contained in:
Meir Shpilraien (Spielrein) 2022-05-03 10:24:05 +03:00 committed by GitHub
parent 87131a5fa6
commit f44c343292
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -1651,8 +1651,11 @@ void luaCallFunction(scriptRunCtx* run_ctx, lua_State *lua, robj** keys, size_t
* {err='<error msg>', source='<source file>', line=<line>}
* We can construct the error message from this information */
if (!lua_istable(lua, -1)) {
/* Should not happened, and we should considered assert it */
addReplyErrorFormat(c,"Error running script (call to %s)\n", run_ctx->funcname);
const char *msg = "execution failure";
if (lua_isstring(lua, -1)) {
msg = lua_tostring(lua, -1);
}
addReplyErrorFormat(c,"Error running script %s, %.100s\n", run_ctx->funcname, msg);
} else {
errorInfo err_info = {0};
sds final_msg = sdsempty();