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
| 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 | * |
nothing calls this directly
no test coverage detected