MCPcopy Create free account
hub / github.com/defold/defold / Sys_SetErrorHandler

Function Sys_SetErrorHandler

engine/script/src/script_sys.cpp:1137–1156  ·  view source on GitHub ↗

set the error handler * * Set the Lua error handler function. * The error handler is a function which is called whenever a lua runtime error occurs. * * @name sys.set_error_handler * @param error_handler [type:function(source, message, traceback)] the function to be called on error * * `source` * : [type:string] The runtime context of the error. Current

Source from the content-addressed store, hash-verified

1135 * ```
1136 */
1137 static int Sys_SetErrorHandler(lua_State* L)
1138 {
1139 int top = lua_gettop(L);
1140 luaL_checktype(L, 1, LUA_TFUNCTION);
1141
1142 // store the supplied function in debug.<SCRIPT_ERROR_HANDLER_VAR> so that it can
1143 // be called from dmScript::PCall
1144 lua_getfield(L, LUA_GLOBALSINDEX, "debug");
1145 if (!lua_istable(L, -1)) {
1146 lua_pop(L, 1);
1147 return 1;
1148 }
1149
1150 lua_pushvalue(L, 1);
1151 lua_setfield(L, -2, SCRIPT_ERROR_HANDLER_VAR);
1152 lua_pop(L, 1);
1153
1154 assert(top == lua_gettop(L));
1155 return 0;
1156 }
1157
1158 /*# set host to check for network connectivity against
1159 *

Callers

nothing calls this directly

Calls 6

lua_gettopFunction · 0.85
luaL_checktypeFunction · 0.85
lua_getfieldFunction · 0.85
lua_pushvalueFunction · 0.85
lua_setfieldFunction · 0.85
assertFunction · 0.50

Tested by

no test coverage detected