Giter Site home page Giter Site logo

Comments (6)

banepwn avatar banepwn commented on May 23, 2024 1

love.errorhandler is supposed to return a function. When detouring it, you need to make sure your function returns the same values as the old one. Do return old_errorhandler(msg).

from lily.

gphg avatar gphg commented on May 23, 2024

I somehow managed to get it right without completely rewrite the errorhandler.

-- cache the function
local old_errorhandler = love.errorhandler
function love.errorhandler(msg)
	-- quit lily before original errorhandler get called
	local lily = package['lily'] or package['libs.lily'] or package['path.to.lily'] or nil
	if lily then 
		lily.quit()
	end
	-- call original cached errorhandler function
	old_errorhandler(msg)
end

from lily.

gphg avatar gphg commented on May 23, 2024

Above solution doesn't work. On unexpected error, the program simply quits without tell any error. I had to uncomment it.

from lily.

gphg avatar gphg commented on May 23, 2024

I debug it, and it seems the old errorhandler is nil.
image

Updated:
I'm on latest stable version. And it is love.errhand, not love.errorhandler. But the wiki page says otherwise. :/

-- Something like this:
local old_errorhandler = love.errorhandler or love.errhand
function love.errorhandler(msg)
	lilyQuit() -- a defined function somewhere to call lily.quit
	return old_errorhandler(msg)
end

from lily.

banepwn avatar banepwn commented on May 23, 2024

That's because LÖVE's default error handler is actually in love.errhand. In the event of an error, LÖVE will check if love.errorhandler exists first, and then love.errhand if it doesn't, then a third inaccessible function if neither exist.

from lily.

gphg avatar gphg commented on May 23, 2024

image
https://love2d.org/wiki/love.errhand
image

Closing this issue.

from lily.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.