Sha256: d40bd64ccdfb78e9e9af637db6c74dfd7989f3e88e207fc08f31a5915198f15f
Contents?: true
Size: 456 Bytes
Versions: 6
Compression:
Stored size: 456 Bytes
Contents
class Exception # Supress errors while executing a block, with execptions. # # CREDIT: Trans # CREDIT: David Heinemeier Hansson def self.suppress(*exception_classes) exception_classes.each do |e| unless e < self raise ArgumentError, "exception #{e} not a subclass of #{self}" end end begin yield rescue Exception => e raise unless exception_classes.any? { |cls| e.kind_of?(cls) } end end end
Version data entries
6 entries across 6 versions & 2 rubygems