diff src/scripts/boot.lua @ 1189:2e57cc4b8749

Make sure love.errhand gets a local reference to print as well, and find the error handler at errortime (partial #390)
author Bart van Strien <bart.bes+projects@gmail.com>
date Fri, 18 Jan 2013 00:55:28 +0100
parents ab6a48fbdd3c
children fd3f318ee46a 5066394222c6
line wrap: on
line diff
--- a/src/scripts/boot.lua	Fri Jan 18 00:48:36 2013 +0100
+++ b/src/scripts/boot.lua	Fri Jan 18 00:55:28 2013 +0100
@@ -682,7 +682,7 @@
 -- 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 @@
 	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 @@
 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