Method: Kernel.suppress
- Defined in:
- activesupport/lib/active_support/core_ext/kernel/reporting.rb
.suppress(*exception_classes) ⇒ Object
Blocks and ignores any exception passed as argument if raised within the block.
suppress(ZeroDivisionError) do
1/0
puts 'This code is NOT reached'
end
puts 'This code gets executed and nothing related to ZeroDivisionError was seen'
41 42 43 44 |
# File 'activesupport/lib/active_support/core_ext/kernel/reporting.rb', line 41 def suppress(*exception_classes) yield rescue *exception_classes end |