Exception: Exception

Defined in:
lib/hammertime19.rb

Instance Method Summary collapse

Instance Method Details

#exception(*args, &block) ⇒ Object



184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/hammertime19.rb', line 184

def exception(*args, &block)
  if ::Hammertime.intercept_native

    # When binding.of_caller(1).pry is called several exceptions
    # are raised but we only want to start a pry session on the
    # first (original) exception.
    # We also don't want to start a pry session if the exception
    # originates from the hammertime library itself (for example
    # when hammertime tries to require ruby-debug)  
    unless caller.any? { |t| t.include?("pry/core_extensions.rb") || t.include?("hammertime_raise") }

      puts "\n"
      puts "=== Stop! Hammertime. ==="
      puts "A C-level error has occurred at #{caller(2).first}"
      puts "The error is: <#{self.class}> #{self.message}"

      binding.of_caller(1).pry
    end
  end

  # Call the original method
  exception_hammertime19_orig(*args, &block)
end

#exception_hammertime19_origObject



183
# File 'lib/hammertime19.rb', line 183

alias_method :exception_hammertime19_orig, :exception