Method: PryExceptionExplorer.intercept
- Defined in:
- lib/pry-exception_explorer.rb
.intercept(*exceptions) {|lazy_frame, exception| ... } ⇒ Object
This method allows the user to assert the situations where an exception interception occurs. This method can be invoked in two ways. The general form takes a block, the block is passed both the frame where the exception was raised, and the exception itself. The user then creates an assertion (a stack-assertion) based on these attributes. If the assertion is later satisfied by a raised exception, that exception will be intercepted. In the second form, the method simply takes an exception class, or a number of exception classes. If one of these exceptions is raised, it will be intercepted.
124 125 126 127 128 129 130 131 132 |
# File 'lib/pry-exception_explorer.rb', line 124 def intercept(*exceptions, &block) return if exceptions.empty? && block.nil? if !exceptions.empty? block = proc { |_, ex| exceptions.any? { |v| v === ex } } end local_hash[:intercept_object] = Intercept.new(block) end |