Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 1, 2010, 1:46:53 PM (14 years ago)
Author:
rgrieder
Message:

Lua errors in 'doFile', 'includeFile' or 'require' should not be caught in theses functions but rather at the beginning of the Lua call.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gamestates2/data/lua/LuaStateInit.lua

    r6665 r6670  
    1616original_dofile = dofile
    1717dofile = function(filename)
    18   luaState:doFile(filename)
     18  if not luaState:doFile(filename) then
     19    error("Error propagation. Do not display")
     20  end
    1921  -- Required because if the file returns a table, it cannot be passed through the C++ function
    2022  return LuaStateReturnValue -- C-injected global variable
     
    2527-- to a function provided to the LuaState constructor (in C++)
    2628include = function(filename)
    27   luaState:includeFile(filename)
     29  if not luaState:includeFile(filename) then
     30    error("Error propagation. Do not display")
     31  end
    2832  -- Required because if the file returns a table, it cannot be passed through the C++ function
    2933  return LuaStateReturnValue -- C-injected global variable
     
    5458    _REQUIREDNAME = moduleName
    5559
    56     luaState:doFile(moduleName .. ".lua")
     60    if not luaState:doFile(moduleName .. ".lua") then
     61      error("Error propagation. Do not display")
     62    end
    5763    -- LuaStateReturnValue is required because if the file returns a table,
    5864    -- it cannot be passed through the C++ function
     
    6672  return asdf
    6773end
     74
     75
     76-- Load useful tool functions (like handleDefaultArgument)
     77require("Tools")
    6878
    6979
     
    8292-- General error handler that gets called whenever an error happens at runtime
    8393errorHandler = function(err)
    84   -- Display the error message
    8594  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
    86100    logMessage(1, "Lua runtime error: "..err)
    87101  end
     
    92106  else
    93107    -- Fallback: print stack trace
    94     logMessage(1, debug.traceback(2))
     108    logMessage(3, debug.traceback(""))
    95109  end
    96110  return err -- Hello Lua debugger user! Please type 'set 2' to get to the
Note: See TracChangeset for help on using the changeset viewer.