lib/fiddle/ffi_backend.rb in fiddle-1.1.3 vs lib/fiddle/ffi_backend.rb in fiddle-1.1.4
- old
+ new
@@ -473,11 +473,14 @@
RTLD_GLOBAL = FFI::DynamicLibrary::RTLD_GLOBAL
RTLD_LAZY = FFI::DynamicLibrary::RTLD_LAZY
RTLD_NOW = FFI::DynamicLibrary::RTLD_NOW
def initialize(libname = nil, flags = RTLD_LAZY | RTLD_GLOBAL)
- @lib = FFI::DynamicLibrary.open(libname, flags) rescue LoadError
- raise DLError.new("Could not open #{libname}") unless @lib
+ begin
+ @lib = FFI::DynamicLibrary.open(libname, flags)
+ rescue LoadError, RuntimeError # LoadError for JRuby, RuntimeError for TruffleRuby
+ raise DLError, "Could not open #{libname}"
+ end
@open = true
begin
yield(self)