IRB swallows exceptions
IRB swallows exceptions, doesn't provide programatic access to raised exception in session.
On Ruby 2.3.4, we find it surprising that exceptions in IRB are swallowed, and are not accessible at the two locations we checked:
- In the global variable for most recent exception
- In the return value of evaluating the expression
Consider this IRB session:
def method_which_raises 1/0 end method_which_raises # ZeroDivisionError: divided by 0 # from (irb):10:in `/' # from (irb):10:in `method_which_raises' # from (irb):13 # from /Users/marcsiegel/.rubies/ruby-2.3.4/bin/irb:11:in `<main>'
$! give access to the raised exception, so that during development or debugging, one could dig further into what had occurred.
$! would give programmatic access in IRB to an exception
irb.rb: restore the last error
lib/irb.rb (eval_input): restore the last error
$!, as the
previous result. [Feature #14684]
lib/irb/context.rb (evaluate): add
to set the last error.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
#5 Updated by nobu (Nobuyoshi Nakada) 8 months ago
- Status changed from Assigned to Closed