Changeset 6670
- Timestamp:
- Apr 1, 2010, 1:46:53 PM (15 years ago)
- Location:
- code/branches/gamestates2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gamestates2/data/lua/LuaStateInit.lua
r6665 r6670 16 16 original_dofile = dofile 17 17 dofile = function(filename) 18 luaState:doFile(filename) 18 if not luaState:doFile(filename) then 19 error("Error propagation. Do not display") 20 end 19 21 -- Required because if the file returns a table, it cannot be passed through the C++ function 20 22 return LuaStateReturnValue -- C-injected global variable … … 25 27 -- to a function provided to the LuaState constructor (in C++) 26 28 include = function(filename) 27 luaState:includeFile(filename) 29 if not luaState:includeFile(filename) then 30 error("Error propagation. Do not display") 31 end 28 32 -- Required because if the file returns a table, it cannot be passed through the C++ function 29 33 return LuaStateReturnValue -- C-injected global variable … … 54 58 _REQUIREDNAME = moduleName 55 59 56 luaState:doFile(moduleName .. ".lua") 60 if not luaState:doFile(moduleName .. ".lua") then 61 error("Error propagation. Do not display") 62 end 57 63 -- LuaStateReturnValue is required because if the file returns a table, 58 64 -- it cannot be passed through the C++ function … … 66 72 return asdf 67 73 end 74 75 76 -- Load useful tool functions (like handleDefaultArgument) 77 require("Tools") 68 78 69 79 … … 82 92 -- General error handler that gets called whenever an error happens at runtime 83 93 errorHandler = function(err) 84 -- Display the error message85 94 if type(err) == "string" then 95 -- Simply return if the error has already been handled 96 if string.find(err, "Error propagation. Do not display") ~= nil then 97 return err 98 end 99 -- Display the error message 86 100 logMessage(1, "Lua runtime error: "..err) 87 101 end … … 92 106 else 93 107 -- Fallback: print stack trace 94 logMessage( 1, debug.traceback(2))108 logMessage(3, debug.traceback("")) 95 109 end 96 110 return err -- Hello Lua debugger user! Please type 'set 2' to get to the -
code/branches/gamestates2/src/libraries/core/LuaState.cc
r6667 r6670 201 201 case LUA_ERRMEM: // Memory allocation error 202 202 COUT(1) << "Lua memory allocation error: Consult your dentist immediately!" << std::endl; 203 lua_pop(luaState_, 1); // Remove error message204 203 break; 205 204 } … … 213 212 { 214 213 case LUA_ERRRUN: // Runtime error 215 // Remove error string from stack(we already display the error in the214 // Do nothing (we already display the error in the 216 215 // 'errorHandler' Lua function in LuaStateInit.lua) 217 216 break; … … 223 222 break; 224 223 } 225 if (error != 0)226 lua_pop(luaState_, 1); // Remove error message227 224 } 228 225 229 226 if (error != 0) 227 { 228 lua_pop(luaState_, 1); // Remove error message 230 229 lua_pushnil(luaState_); // Push a nil return value 230 } 231 231 232 232 if (errorHandler != 0)
Note: See TracChangeset
for help on using the changeset viewer.