MCPcopy Create free account
hub / github.com/F-Stack/f-stack / luaPushError

Function luaPushError

app/redis-6.2.6/src/scripting.c:286–308  ·  view source on GitHub ↗

This function is used in order to push an error on the Lua stack in the * format used by redis.pcall to return errors, which is a lua table * with a single "err" field set to the error string. Note that this * table is never a valid reply by proper commands, since the returned * tables are otherwise always indexed by integers, never by strings. */

Source from the content-addressed store, hash-verified

284 * table is never a valid reply by proper commands, since the returned
285 * tables are otherwise always indexed by integers, never by strings. */
286void luaPushError(lua_State *lua, char *error) {
287 lua_Debug dbg;
288
289 /* If debugging is active and in step mode, log errors resulting from
290 * Redis commands. */
291 if (ldb.active && ldb.step) {
292 ldbLog(sdscatprintf(sdsempty(),"<error> %s",error));
293 }
294
295 lua_newtable(lua);
296 lua_pushstring(lua,"err");
297
298 /* Attempt to figure out where this function was called, if possible */
299 if(lua_getstack(lua, 1, &dbg) && lua_getinfo(lua, "nSl", &dbg)) {
300 sds msg = sdscatprintf(sdsempty(), "%s: %d: %s",
301 dbg.source, dbg.currentline, error);
302 lua_pushstring(lua, msg);
303 sdsfree(msg);
304 } else {
305 lua_pushstring(lua, error);
306 }
307 lua_settable(lua,-3);
308}
309
310/* In case the error set into the Lua stack by luaPushError() was generated
311 * by the non-error-trapping version of redis.pcall(), which is redis.call(),

Callers 2

luaRedisGenericCommandFunction · 0.85

Calls 8

ldbLogFunction · 0.85
sdscatprintfFunction · 0.85
sdsemptyFunction · 0.85
sdsfreeFunction · 0.85
lua_pushstringFunction · 0.50
lua_getstackFunction · 0.50
lua_getinfoFunction · 0.50
lua_settableFunction · 0.50

Tested by

no test coverage detected