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
Updated by nobu (Nobuyoshi Nakada) over 3 years ago
- Status changed from Assigned to Closed