My project uses an external library that I want to make optional. If it can't load, I would like to continue on without using it rather than halt the program. Can I do this?
I can't just disable the LOVE error handler - that only makes it close the window rather than show the blue error screen.
Can I make ffi.load error nonfatal?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 36
- Joined: Wed Apr 13, 2016 3:53 pm
- slime
- Solid Snayke
- Posts: 3131
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Can I make ffi.load error nonfatal?
You can use pcall.
Code: Select all
local status, lib = pcall(ffi.load, "mylibrary")
if status then
lib.foo(bar)
end
-
- Prole
- Posts: 36
- Joined: Wed Apr 13, 2016 3:53 pm
Re: Can I make ffi.load error nonfatal?
Thanks slime. Works for me.slime wrote:You can use pcall.
Code: Select all
local status, lib = pcall(ffi.load, "mylibrary") if status then lib.foo(bar) end
Who is online
Users browsing this forum: Majestic-12 [Bot] and 49 guests