MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / luabb_error

Function luabb_error

lua/luautil.c:230–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

228}
229
230int luabb_error(Lua lua, SP sp, const char *fmt, ...)
231{
232 char c[1];
233 va_list args;
234 int len;
235 char *out = NULL;
236 va_start(args, fmt);
237 len = vsnprintf(c, 1, fmt, args);
238 va_end(args);
239
240 if (len == 0)
241 out = sp ? strdup("") : "";
242 else if (len < 0)
243 luaL_error(lua, "can't format string");
244 else {
245 out = sp ? malloc(len + 2) : alloca(len + 2);
246 va_start(args, fmt);
247 vsnprintf(out, len+1, fmt, args);
248 out[len+1] = 0;
249 va_end(args);
250 }
251
252 extern int gbl_allow_lua_print;
253 if (gbl_allow_lua_print) {
254 luaL_where(lua, 0);
255 lua_pop(lua, 1);
256#if 0
257 const char *src = lua_tostring(lua, -1);
258 if (sp && sp->spname)
259 fprintf(stderr, "ERROR in SP:%s Ver:%d %s:%s\n",
260 sp->spname, sp->spversion, out, src);
261 else
262 fprintf(stderr, "ERROR:%s %s]\n", src, out);
263#endif
264 }
265
266 if (sp) {
267 if(sp->rc == 0)
268 sp->rc = -1;
269 lua_pushnil(lua);
270 lua_pushnumber(lua, sp->rc);
271 if (sp->error)
272 free(sp->error);
273 sp->error = out;
274 return 1; /* Just returning error code. */
275 } else {
276 lua_pushnumber(lua, -1);
277 return luaL_error(lua, out);
278 }
279}
280
281int luabb_type_by_name_int(const char *name, dbtypes_enum min)
282{

Callers 15

typecmperrFunction · 0.85
luabb_type_err_intFunction · 0.85
l_typed_assignmentFunction · 0.85
csv_read_one_fieldFunction · 0.85
check_retry_conditionsFunction · 0.85
luabb_trigger_registerFunction · 0.85
dbq_poll_intFunction · 0.85
dbq_pollFunction · 0.85
create_temp_tableFunction · 0.85
comdb2_tableFunction · 0.85
new_temp_tableFunction · 0.85
get_remote_inputFunction · 0.85

Calls 7

luaL_errorFunction · 0.85
mallocFunction · 0.85
luaL_whereFunction · 0.85
lua_pushnilFunction · 0.85
lua_pushnumberFunction · 0.85
freeFunction · 0.85
strdupFunction · 0.50

Tested by

no test coverage detected