Sha256: 2015beb0ef72d9427504c487f8e14cd12ff3295a20c5f14e016c5408ff470b69

Contents?: true

Size: 406 Bytes

Versions: 3

Compression:

Stored size: 406 Bytes

Contents

module Kernel

  # Supress errors while executing a block, with execptions.
  #
  # TODO: This will be deprecatd in favor or Exception#suppress.
  #
  #  CREDIT: David Heinemeier Hansson

  def suppress(*exception_classes)
    warn "use Exception#supress for future versions"
    begin yield
    rescue Exception => e
      raise unless exception_classes.any? { |cls| e.kind_of?(cls) }
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facets-2.4.1 lib/facets/kernel/suppress.rb
facets-2.4.2 lib/core/facets/kernel/suppress.rb
facets-2.4.3 lib/core/facets/kernel/suppress.rb