Exception needs to be restored in case two are in flight at once.

def foo
  p $! # NameError from below
  begin
    raise StandardError, "bar"
  rescue
    p $! # StandardError from above
  end
  p $! # NameError from below
end

begin
  bar
rescue
  p $! # NameError
  foo
  p $! # Still NameError
end