Module: Wrong::Rescuing

Included in:
Helpers
Defined in:
lib/wrong/rescuing.rb

Instance Method Summary collapse

Instance Method Details

#rescuingObject

Executes a block that is expected to raise an exception. Returns that exception, or nil if none was raised.



5
6
7
8
9
10
11
12
13
# File 'lib/wrong/rescuing.rb', line 5

def rescuing
  error = nil
  begin
    yield
  rescue Exception, RuntimeError => e
    error = e
  end
  error
end