File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -475,8 +475,11 @@ class Handle
475475 RTLD_NOW = FFI ::DynamicLibrary ::RTLD_NOW
476476
477477 def initialize ( libname = nil , flags = RTLD_LAZY | RTLD_GLOBAL )
478- @lib = FFI ::DynamicLibrary . open ( libname , flags ) rescue LoadError
479- raise DLError . new ( "Could not open #{ libname } " ) unless @lib
478+ begin
479+ @lib = FFI ::DynamicLibrary . open ( libname , flags )
480+ rescue
481+ raise DLError , "Could not open #{ libname } "
482+ end
480483
481484 @open = true
482485
Original file line number Diff line number Diff line change @@ -8,6 +8,15 @@ module Fiddle
88 class TestHandle < TestCase
99 include Fiddle
1010
11+ def test_library_unavailable
12+ assert_raise ( DLError ) do
13+ Fiddle ::Handle . new ( "does-not-exist-library" )
14+ end
15+ assert_raise ( DLError ) do
16+ Fiddle ::Handle . new ( "/does/not/exist/library.#{ RbConfig ::CONFIG [ 'SOEXT' ] } " )
17+ end
18+ end
19+
1120 def test_to_i
1221 if ffi_backend?
1322 omit ( "Fiddle::Handle#to_i is unavailable with FFI backend" )
You can’t perform that action at this time.
0 commit comments