- FATAL_ERROR_IF(lua_gettop(L) < nargs + 1, "Not enough arguments");
-
- // Insert error handler
- PUSH_ERROR_HANDLER(L);
- int error_handler = lua_gettop(L) - nargs - 1;
- lua_insert(L, error_handler);
-
- // Insert run_callbacks between error handler and table
- lua_getglobal(L, "core");
- lua_getfield(L, -1, "run_callbacks");
- lua_remove(L, -2);
- lua_insert(L, error_handler + 1);
+ lua_Debug ar;
+
+ if (lua_getstack(L, stack_depth, &ar)) {
+ FATAL_ERROR_IF(!lua_getinfo(L, "Sl", &ar), "lua_getinfo() failed");
+ message.append(" (at " + std::string(ar.short_src) + ":"
+ + std::to_string(ar.currentline) + ")");
+ } else {
+ message.append(" (at ?:?)");
+ }
+}