Make sure love.errhand gets a local reference to print as well, and find the error handler at errortime (partial #390)

This commit is contained in:
Bart van Strien
2013-01-18 00:55:28 +01:00
parent 501beb7d02
commit a72c981c32
2 changed files with 24 additions and 13 deletions
+8 -3
View File
@@ -682,7 +682,7 @@ end
-- Error screen.
-----------------------------------------------------------
local debug = debug
local debug, print = debug, print
local function error_printer(msg, layer)
print((debug.traceback("Error: " .. tostring(msg), 1+(layer or 1)):gsub("\n[^\n]+$", "")))
@@ -801,6 +801,11 @@ function love.releaseerrhand(msg)
end
end
local function deferErrhand(...)
local handler = ((love._release and love.releaseerrhand) or love.errhand or error_printer)
return handler(...)
end
-----------------------------------------------------------
-- The root of all calls.
@@ -809,9 +814,9 @@ end
return function()
local result = xpcall(love.boot, error_printer)
if not result then return 1 end
local result = xpcall(love.init, love._release and love.releaseerrhand or love.errhand)
local result = xpcall(love.init, deferErrhand)
if not result then return 1 end
local result, retval = xpcall(love.run, love._release and love.releaseerrhand or love.errhand)
local result, retval = xpcall(love.run, deferErrhand)
if not result then return 1 end
return tonumber(retval) or 0