Method: Corosync.cs_send!
- Defined in:
- lib/corosync.rb
.cs_send!(method, *args) ⇒ TrueClass, Integer
Calls a Corosync method and raises an exception on errors. This is a convenience method to handle error responses when calling various corosync library functions. When an error is returned, an exception is raised. The exceptions are programatically generated based off the ‘:cs_error_t` enum defined in `ffi/common.rb`. For example, `:err_try_again` maps to `Corosync::TryAgainError`.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/corosync.rb', line 18 def self.cs_send!(method, *args) cs_error = nil begin cs_error = send(method, *args) rescue Corosync::Error => e e.depth += 1 raise e end return true if cs_error == :ok # short circuit the rest of the method since this should be true the majority of the time if exception_class = Error::Map[cs_error] then exception = exception_class.new("Received #{cs_error.to_s.upcase} during #{method}") exception.depth = 1 raise exception end cs_error end |