Module: Gemmy::Patches::ExceptionPatch::ClassMethods::Suppress

Defined in:
lib/gemmy/patches/exception_patch.rb

Instance Method Summary collapse

Instance Method Details

#suppress(*err_classes) ⇒ Object

facets



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/gemmy/patches/exception_patch.rb', line 20

def suppress(*err_classes)
  err_classes.each do |e|
    unless e < self
      raise ArgumentError, "exception #{e} not a subclass of #{self}"
    end
  end
  err_classes = err_classes.empty? ? [self] : err_classes
  begin
    yield
  rescue Exception => e
    raise unless err_classes.any? { |cls| e.kind_of?(cls) }
  end
end