Navigation Menu

Skip to content
This repository has been archived by the owner on Oct 16, 2019. It is now read-only.

Commit

Permalink
Raise a unique exception if libvirt C library not available.
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Dec 8, 2010
1 parent d06c4ae commit 942d213
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
@@ -1,6 +1,7 @@
## 0.2.1 (unreleased)


- `FFI::Libvirt::MissingLibError` is raised if libvirt C library
is not available.

## 0.2.0 (December 7, 2010)

Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
libvirt (0.2.0)
libvirt (0.2.1.dev)
ffi (~> 0.6.3)
nokogiri (~> 1.4.3)

Expand Down
13 changes: 11 additions & 2 deletions lib/ffi/libvirt.rb
Expand Up @@ -7,10 +7,19 @@ module FFI
# that it is up to you to manage all the pointers and so on that come
# with this power.
module Libvirt
autoload :MissingLibError, 'ffi/libvirt/exception'
autoload :Util, 'ffi/libvirt/util'

extend FFI::Library
ffi_lib "libvirt"

autoload :Util, 'ffi/libvirt/util'
# Attempt to load the libvirt lib and raise a more specific exception
# if it doesn't exist. (Normally a LoadError, which is ambiguous, is
# raised)
begin
ffi_lib "libvirt"
rescue LoadError
raise MissingLibError
end
end
end

Expand Down
10 changes: 10 additions & 0 deletions lib/ffi/libvirt/exception.rb
@@ -0,0 +1,10 @@
module FFI
module Libvirt
# Error raised when the libvirt C library is missing.
class MissingLibError < StandardError
def initialize
super("The libvirt C library could not be loaded. Is it properly installed?")
end
end
end
end

0 comments on commit 942d213

Please sign in to comment.